zoukankan      html  css  js  c++  java
  • 谁说编译器不SB

    我有这么一段代码,我使用的是VS2010IDE,直接编译Release模式,开O2,谁能猜到编译器怎么给我编的

      1 typedef HRESULT (__stdcall *FTSHGetFolderLocation)(HWND hwndOwner,
      2     int nFolder,
      3     HANDLE hToken,
      4     DWORD dwReserved,
      5     void *ppidl
      6     );
      7 typedef HRESULT (__stdcall *FTSHGetFolderPathW)(
      8     _In_  HWND   hwndOwner,
      9     _In_  int    nFolder,
     10     _In_  HANDLE hToken,
     11     _In_  DWORD  dwFlags,
     12     _Out_ LPTSTR pszPath
     13     );
     14 typedef BOOL (__stdcall *FTSHGetPathFromIDListW)(
     15     _In_  void *pidl,
     16     _Out_ LPTSTR            pszPath
     17     );
     18 typedef void (__stdcall *FTILFree)(
     19     _In_ VOID *pidl
     20     );
     21 typedef BOOL (WINAPI *FTGetFileAttributesExW)(
     22     __in LPCWSTR lpFileName,
     23     __in GET_FILEEX_INFO_LEVELS fInfoLevelId,
     24     __out LPVOID lpFileInformation
     25     );
     26 typedef BOOL (WINAPI *FTCreateDirectoryA)(
     27     __in          LPCSTR lpPathName,
     28     __in          LPSECURITY_ATTRIBUTES lpSecurityAttributes
     29     );
     30 typedef DWORD (WINAPI *FTGetTempPathA)(
     31     _In_  DWORD  nBufferLength,
     32     _Out_ LPSTR lpBuffer
     33     );
     34 
     35 typedef WINADVAPI LSTATUS (APIENTRY *FTRegOpenKeyExW) (
     36     __in HKEY hKey,
     37     __in_opt LPCWSTR lpSubKey,
     38     __reserved DWORD ulOptions,
     39     __in REGSAM samDesired,
     40     __out PHKEY phkResult
     41     );
     42 
     43 typedef WINADVAPI
     44     LSTATUS
     45     (APIENTRY *FTRegQueryValueExW)(
     46     __in HKEY hKey,
     47     __in_opt LPCWSTR lpValueName,
     48     __reserved LPDWORD lpReserved,
     49     __out_opt LPDWORD lpType,
     50     __out_bcount_part_opt(*lpcbData, *lpcbData) __out_data_source(REGISTRY) LPBYTE lpData,
     51     __inout_opt LPDWORD lpcbData
     52     );
     53 
     54 typedef WINADVAPI
     55     LSTATUS
     56     (APIENTRY *FTRegCloseKey)(
     57     __in HKEY hKey
     58     );
     59 
     60 typedef HRESULT (__stdcall* FTCoInitialize)(
     61     _In_opt_ LPVOID pvReserved
     62     );
     63 
     64 typedef HRESULT (__stdcall* FTCoCreateInstance)(
     65     __in     REFCLSID rclsid, 
     66     __in_opt LPUNKNOWN pUnkOuter,
     67     __in     DWORD dwClsContext, 
     68     __in     REFIID riid, 
     69     __deref_out LPVOID FAR* ppv);
     70 
     71 typedef void (__stdcall* FTCoUninitialize)(void);
     72 
     73 typedef BOOL (__stdcall* FTPathRemoveFileSpecW)(
     74     __inout LPWSTR pszPath
     75     );
     76 
     77 typedef BOOL (WINAPI* FTDeleteFileW)(
     78     _In_ LPCWSTR lpFileName
     79     );
     80 
     81 
     82 #define START_FUNC_ARRAY()                    
     83 struct FunctionArray                        
     84 {                                            
     85     long                size
     86 #define ADD_FUN_ARRAY(_M_, _N_)                
     87     FT ## _N_            p ## _N_
     88 #define END_FUNC_ARRAY()                    
     89 }
     90 
     91 
     92 #define GET_MODE_PROC_ADDRESS(_M_, _F_, _T_, _V_)                
     93     do                                                            
     94     {                                                            
     95         _V_ = (_T_)GetProcAddress(::LoadLibraryA(_M_), _F_);    
     96         if (_V_ == NULL)                                        
     97         {                                                        
     98             ErrorLog();                                            
     99             return FALSE;                                        
    100         }                                                        
    101     } while (FALSE)
    102 
    103 #define GET_PROC_ADDRESS(__M_, __F_)    
    104     GET_MODE_PROC_ADDRESS(__M_, #__F_, FT ## __F_, g_funArray.p ## __F_)
    105 
    106 #define CALL(_F_)    
    107     g_funArray.p ## _F_
    108 
    109 
    110 
    111 START_FUNC_ARRAY();
    112     ADD_FUN_ARRAY("shell32.dll", SHGetFolderLocation);
    113     ADD_FUN_ARRAY("shell32.dll", SHGetFolderPathW);
    114     ADD_FUN_ARRAY("shell32.dll", SHGetPathFromIDListW);
    115     ADD_FUN_ARRAY("shell32.dll", ILFree);
    116 
    117     ADD_FUN_ARRAY("Kernel32.dll", GetFileAttributesExW);
    118     ADD_FUN_ARRAY("Kernel32.dll", CreateDirectoryA);
    119     ADD_FUN_ARRAY("Kernel32.dll", GetTempPathA);
    120     ADD_FUN_ARRAY("Kernel32.dll", DeleteFileW);
    121 
    122     ADD_FUN_ARRAY("Advapi32.dll", RegOpenKeyExW);
    123     ADD_FUN_ARRAY("Advapi32.dll", RegQueryValueExW);
    124     ADD_FUN_ARRAY("Advapi32.dll", RegCloseKey);
    125 
    126     ADD_FUN_ARRAY("Ole32.dll", CoInitialize);
    127     ADD_FUN_ARRAY("Ole32.dll", CoCreateInstance);
    128     ADD_FUN_ARRAY("Ole32.dll", CoUninitialize);
    129 
    130     ADD_FUN_ARRAY("Shlwapi.dll", PathRemoveFileSpecW);
    131 END_FUNC_ARRAY();
    132 
    133 
    134 
    135 FunctionArray g_funArray = {sizeof(FunctionArray)};
    136 
    137 BOOL InitFunction()
    138 {
    139     GET_PROC_ADDRESS("shell32.dll"        , SHGetFolderLocation);
    140     GET_PROC_ADDRESS("shell32.dll"        , SHGetFolderPathW);
    141     GET_PROC_ADDRESS("shell32.dll"        , SHGetPathFromIDListW);
    142     GET_PROC_ADDRESS("shell32.dll"        , ILFree);
    143 
    144     GET_PROC_ADDRESS("Kernel32.dll"        , GetFileAttributesExW);
    145     GET_PROC_ADDRESS("Kernel32.dll"        , CreateDirectoryA);
    146     GET_PROC_ADDRESS("Kernel32.dll"        , GetTempPathA);
    147     GET_PROC_ADDRESS("Kernel32.dll"        , DeleteFileW);
    148 
    149     GET_PROC_ADDRESS("Advapi32.dll"        , RegOpenKeyExW);
    150     GET_PROC_ADDRESS("Advapi32.dll"        , RegQueryValueExW);
    151     GET_PROC_ADDRESS("Advapi32.dll"        , RegCloseKey);
    152 
    153     GET_PROC_ADDRESS("Ole32.dll"        , CoInitialize);
    154     GET_PROC_ADDRESS("Ole32.dll"        , CoCreateInstance);
    155     GET_PROC_ADDRESS("Ole32.dll"        , CoUninitialize);
    156 
    157     GET_PROC_ADDRESS("Shlwapi.dll"        , PathRemoveFileSpecW);
    158     return TRUE;
    159 }

    先猜猜看,猜不到的往下看

      1 ; __int64 Initialize(void)
      2 ?Initialize@@YAHXZ proc near            ; CODE XREF: DllMain+51p
      3                                         ; DATA XREF: .pdata:000000018000E060o
      4                 sub     rsp, 28h
      5                 lea     rcx, LibFileName ; "shell32.dll"
      6                 call    cs:LoadLibraryA
      7                 lea     rdx, ProcName   ; "SHGetFolderLocation"
      8                 mov     rcx, rax        ; hModule
      9                 call    cs:GetProcAddress
     10                 mov     cs:qword_18000CED0, rax
     11                 test    rax, rax
     12                 jnz     short loc_180002154
     13 
     14 loc_18000214D:                          ; CODE XREF: Initialize(void)+5Bj
     15                                         ; Initialize(void)+84j ...
     16                 xor     eax, eax
     17                 add     rsp, 28h
     18                 retn
     19 ; ---------------------------------------------------------------------------
     20 
     21 loc_180002154:                          ; CODE XREF: Initialize(void)+2Bj
     22                 lea     rcx, LibFileName ; "shell32.dll"
     23                 call    cs:LoadLibraryA
     24                 lea     rdx, aShgetfolderpat ; "SHGetFolderPathW"
     25                 mov     rcx, rax        ; hModule
     26                 call    cs:GetProcAddress
     27                 mov     cs:qword_18000CED8, rax
     28                 test    rax, rax
     29                 jz      short loc_18000214D
     30                 lea     rcx, LibFileName ; "shell32.dll"
     31                 call    cs:LoadLibraryA
     32                 lea     rdx, aShgetpathfromi ; "SHGetPathFromIDListW"
     33                 mov     rcx, rax        ; hModule
     34                 call    cs:GetProcAddress
     35                 mov     cs:qword_18000CEE0, rax
     36                 test    rax, rax
     37                 jz      short loc_18000214D
     38                 lea     rcx, LibFileName ; "shell32.dll"
     39                 call    cs:LoadLibraryA
     40                 lea     rdx, aIlfree    ; "ILFree"
     41                 mov     rcx, rax        ; hModule
     42                 call    cs:GetProcAddress
     43                 mov     cs:qword_18000CEE8, rax
     44                 test    rax, rax
     45                 jz      loc_18000214D
     46                 lea     rcx, aKernel32_dll_0 ; "Kernel32.dll"
     47                 call    cs:LoadLibraryA
     48                 lea     rdx, aGetfileattribu ; "GetFileAttributesExW"
     49                 mov     rcx, rax        ; hModule
     50                 call    cs:GetProcAddress
     51                 mov     cs:qword_18000CEF0, rax
     52                 test    rax, rax
     53                 jz      loc_18000214D
     54                 lea     rcx, aKernel32_dll_0 ; "Kernel32.dll"
     55                 call    cs:LoadLibraryA
     56                 lea     rdx, aCreatedirector ; "CreateDirectoryA"
     57                 mov     rcx, rax        ; hModule
     58                 call    cs:GetProcAddress
     59                 mov     cs:qword_18000CEF8, rax
     60                 test    rax, rax
     61                 jz      loc_18000214D
     62                 lea     rcx, aKernel32_dll_0 ; "Kernel32.dll"
     63                 call    cs:LoadLibraryA
     64                 lea     rdx, aGettemppatha ; "GetTempPathA"
     65                 mov     rcx, rax        ; hModule
     66                 call    cs:GetProcAddress
     67                 mov     cs:qword_18000CF00, rax
     68                 test    rax, rax
     69                 jz      loc_18000214D
     70                 lea     rcx, aKernel32_dll_0 ; "Kernel32.dll"
     71                 call    cs:LoadLibraryA
     72                 lea     rdx, aDeletefilew ; "DeleteFileW"
     73                 mov     rcx, rax        ; hModule
     74                 call    cs:GetProcAddress
     75                 mov     cs:qword_18000CF40, rax
     76                 test    rax, rax
     77                 jz      loc_18000214D
     78                 lea     rcx, aAdvapi32_dll ; "Advapi32.dll"
     79                 call    cs:LoadLibraryA
     80                 lea     rdx, aRegopenkeyexw ; "RegOpenKeyExW"
     81                 mov     rcx, rax        ; hModule
     82                 call    cs:GetProcAddress
     83                 mov     cs:qword_18000CF08, rax
     84                 test    rax, rax
     85                 jz      loc_18000214D
     86                 lea     rcx, aAdvapi32_dll ; "Advapi32.dll"
     87                 call    cs:LoadLibraryA
     88                 lea     rdx, aRegqueryvaluee ; "RegQueryValueExW"
     89                 mov     rcx, rax        ; hModule
     90                 call    cs:GetProcAddress
     91                 mov     cs:qword_18000CF10, rax
     92                 test    rax, rax
     93                 jz      loc_18000214D
     94                 lea     rcx, aAdvapi32_dll ; "Advapi32.dll"
     95                 call    cs:LoadLibraryA
     96                 lea     rdx, aRegclosekey ; "RegCloseKey"
     97                 mov     rcx, rax        ; hModule
     98                 call    cs:GetProcAddress
     99                 mov     cs:qword_18000CF18, rax
    100                 test    rax, rax
    101                 jz      loc_18000214D
    102                 lea     rcx, aOle32_dll ; "Ole32.dll"
    103                 call    cs:LoadLibraryA
    104                 lea     rdx, aCoinitialize ; "CoInitialize"
    105                 mov     rcx, rax        ; hModule
    106                 call    cs:GetProcAddress
    107                 mov     cs:qword_18000CF20, rax
    108                 test    rax, rax
    109                 jz      loc_18000214D
    110                 lea     rcx, aOle32_dll ; "Ole32.dll"
    111                 call    cs:LoadLibraryA
    112                 lea     rdx, aCocreateinstan ; "CoCreateInstance"
    113                 mov     rcx, rax        ; hModule
    114                 call    cs:GetProcAddress
    115                 mov     cs:qword_18000CF28, rax
    116                 test    rax, rax
    117                 jz      loc_18000214D
    118                 lea     rcx, aOle32_dll ; "Ole32.dll"
    119                 call    cs:LoadLibraryA
    120                 lea     rdx, aCouninitialize ; "CoUninitialize"
    121                 mov     rcx, rax        ; hModule
    122                 call    cs:GetProcAddress
    123                 mov     cs:qword_18000CF30, rax
    124                 test    rax, rax
    125                 jz      loc_18000214D
    126                 lea     rcx, aShlwapi_dll ; "Shlwapi.dll"
    127                 call    cs:LoadLibraryA
    128                 lea     rdx, aPathremovefile ; "PathRemoveFileSpecW"
    129                 mov     rcx, rax        ; hModule
    130                 call    cs:GetProcAddress
    131                 xor     ecx, ecx
    132                 test    rax, rax
    133                 mov     cs:qword_18000CF38, rax
    134                 setnz   cl
    135                 mov     eax, ecx
    136                 add     rsp, 28h
    137                 retn
    138 ?Initialize@@YAHXZ endp
    139 
    140 ; ---------------------------------------------------------------------------
    View Code
  • 相关阅读:
    博客CSS样式 二
    产品经理
    HttpClient调用doGet、doPost、JSON传参及获得返回值
    Maven无法下载com.oracle:ojdbc.jar解决方法
    EasyExcel导入导出
    centos7 安装supervisor教程以及常见问题
    Django与Celery的安装使用
    亚马逊广告api v2版php扩展库
    Mac VMware Fusion CentOS7 安装、配置静态IP文档
    常见Web安全问题攻防解析
  • 原文地址:https://www.cnblogs.com/suanguade/p/7072141.html
Copyright © 2011-2022 走看看