`json.load()`和`json.loads()`都是Python標準庫`json`模塊中用於處理JSON數據的方法,二者的作用都是將JSON數據轉換為Python數據類型,它們之間的區別如下: ### 1. `json.load()`是從文件中讀取JSON數據 `json.load()`用於 ...
在有些破解程式時,不能暴力修改程式,修改後,程式就不能正常運行,因為很多程式啟動時有自我的校驗,但是當程式載入到記憶體後,在記憶體中修改相應的地方就可以達到破解的效果。那麼怎樣在不破壞程式的前提下,達到修改程式呢?
當一個可執行文件運行時,Windows載入器將可執行模塊映射到進程的地址空間中,載入器分析可執行模塊的輸入表,並設法找出任何需要的DLL,並將它們映射到進程的地址空間中。由於輸入表中只包含DLL名而沒有它的路徑名,因此載入程式必須在磁碟上搜索DLL文件。首先會嘗試從當前程式所在的目錄載入DLL,如果沒找到,則在Windows系統目錄查找,最後是在環境變數中列出的各個目錄下查找。利用這個特點,先偽造一個系統同名的DLL,提供同樣的輸出表,每個輸出函數轉向真正的系統DLL。程式調用系統DLL時會先調用當前目錄下偽造的DLL,完成相關功能後,再跳到系統DLL同名函數里執行。這個過程用個形象的詞來描述就是系統DLL被劫持了。
我們常用的系統的DLL有:
lpk.dll、msimg32.dll、version.dll、winmm.dll、usp10.dll、uxtheme.dll 等
為了完成對軟體的破解,需要按以下步驟進行:
1、首先分析要破解的軟體(以ZY_Modbus_Slave_sim.exe為例)調用了那些系統的dll文件,可以使用微軟出品的進程資源管理器procexp64 https://download.sysinternals.com/files/ProcessExplorer.zip
該軟體調用了操作系統的uxtheme.dll文件
2、使用dllexp工具,分析出該系統untheme.dll的所有函數
將所有的函數名稱保留出來,如下:
3、打開Delphi,創建一個Dll文件項目,項目名稱修改保存為uxtheme,
根據每個函數名新建一個對應的指針,例如:
BeginBufferedAnimation 新建一個指針 PoldBeginBufferedAnimation: Pointer; 對應創建一個過程: procedure BeginBufferedAnimation; asm jmp PoldBeginBufferedAnimation end; 即原程式調用BeginBufferedAnimation函數時,自動調用 PoldBeginBufferedAnimation 程式在啟動時 將PoldBeginBufferedAnimation 指向原系統的 BeginBufferedAnimation函數 PoldBeginBufferedAnimation := GetProcAddress(ModHandle, 'BeginBufferedAnimation'); 這樣就可以在dll運行時將所有的函數指向原系統的函數,同時可以在程式中加入自己的代碼,到達不破壞原程式而進行記憶體修改程式的功能。 4、編程程式,生成untheme.dll文件 5、將untheme.dll文件拷貝到ZY_Modbus_Slave_sim.exe文件所在目錄中,就可以完成記憶體補丁的破解工作。 ZY_Modbus_Slave_sim在啟動調用untheme.dll時,自動調用執行同目錄的這個文件。其樣常式序如下(其中使用定時器在工作,具體可不使用這種方法,具體情況具體分析了):
1 library uxtheme; 2 3 uses 4 Winapi.Windows, 5 Winapi.TlHelp32, Winapi.mmsystem, 6 Winapi.PsAPI, 7 System.SysUtils, 8 System.Classes; 9 {$R *.res} 10 var 11 ModHandle: Cardinal; 12 CCID: DWORD; 13 MMTimerID: Integer; // 定時器ID 14 15 16 PoldBeginBufferedAnimation: Pointer; 17 PoldBeginBufferedPaint: Pointer; 18 PoldBeginPanningFeedback: Pointer; 19 PoldBufferedPaintClear: Pointer; 20 PoldBufferedPaintInit: Pointer; 21 PoldBufferedPaintRenderAnimation: Pointer; 22 PoldBufferedPaintSetAlpha: Pointer; 23 PoldBufferedPaintStopAllAnimations: Pointer; 24 PoldBufferedPaintUnInit: Pointer; 25 PoldCloseThemeData: Pointer; 26 PoldDllCanUnloadNow: Pointer; 27 PoldDllGetActivationFactory: Pointer; 28 PoldDllGetClassObject: Pointer; 29 PoldDrawThemeBackground: Pointer; 30 PoldDrawThemeBackgroundEx: Pointer; 31 PoldDrawThemeEdge: Pointer; 32 PoldDrawThemeIcon: Pointer; 33 PoldDrawThemeParentBackground: Pointer; 34 PoldDrawThemeParentBackgroundEx: Pointer; 35 PoldDrawThemeText: Pointer; 36 PoldDrawThemeTextEx: Pointer; 37 PoldEnableThemeDialogTexture: Pointer; 38 PoldEnableTheming: Pointer; 39 PoldEndBufferedAnimation: Pointer; 40 PoldEndBufferedPaint: Pointer; 41 PoldEndPanningFeedback: Pointer; 42 PoldGetBufferedPaintBits: Pointer; 43 PoldGetBufferedPaintDC: Pointer; 44 PoldGetBufferedPaintTargetDC: Pointer; 45 PoldGetBufferedPaintTargetRect: Pointer; 46 PoldGetColorFromPreference: Pointer; 47 PoldGetCurrentThemeName: Pointer; 48 PoldGetImmersiveColorFromColorSetEx: Pointer; 49 PoldGetImmersiveUserColorSetPreference: Pointer; 50 PoldGetThemeAnimationProperty: Pointer; 51 PoldGetThemeAnimationTransform: Pointer; 52 PoldGetThemeAppProperties: Pointer; 53 PoldGetThemeBackgroundContentRect: Pointer; 54 PoldGetThemeBackgroundExtent: Pointer; 55 PoldGetThemeBackgroundRegion: Pointer; 56 PoldGetThemeBitmap: Pointer; 57 PoldGetThemeBool: Pointer; 58 PoldGetThemeColor: Pointer; 59 PoldGetThemeDocumentationProperty: Pointer; 60 PoldGetThemeEnumValue: Pointer; 61 PoldGetThemeFilename: Pointer; 62 PoldGetThemeFont: Pointer; 63 PoldGetThemeInt: Pointer; 64 PoldGetThemeIntList: Pointer; 65 PoldGetThemeMargins: Pointer; 66 PoldGetThemeMetric: Pointer; 67 PoldGetThemePartSize: Pointer; 68 PoldGetThemePosition: Pointer; 69 PoldGetThemePropertyOrigin: Pointer; 70 PoldGetThemeRect: Pointer; 71 PoldGetThemeStream: Pointer; 72 PoldGetThemeString: Pointer; 73 PoldGetThemeSysBool: Pointer; 74 PoldGetThemeSysColor: Pointer; 75 PoldGetThemeSysColorBrush: Pointer; 76 PoldGetThemeSysFont: Pointer; 77 PoldGetThemeSysInt: Pointer; 78 PoldGetThemeSysSize: Pointer; 79 PoldGetThemeSysString: Pointer; 80 PoldGetThemeTextExtent: Pointer; 81 PoldGetThemeTextMetrics: Pointer; 82 PoldGetThemeTimingFunction: Pointer; 83 PoldGetThemeTransitionDuration: Pointer; 84 PoldGetUserColorPreference: Pointer; 85 PoldGetWindowTheme: Pointer; 86 PoldHitTestThemeBackground: Pointer; 87 PoldIsAppThemed: Pointer; 88 PoldIsCompositionActive: Pointer; 89 PoldIsThemeActive: Pointer; 90 PoldIsThemeBackgroundPartiallyTransparent: Pointer; 91 PoldIsThemeDialogTextureEnabled: Pointer; 92 PoldIsThemePartDefined: Pointer; 93 PoldOpenThemeData: Pointer; 94 PoldOpenThemeDataEx: Pointer; 95 PoldOpenThemeDataForDpi: Pointer; 96 PoldSetThemeAppProperties: Pointer; 97 PoldSetWindowTheme: Pointer; 98 PoldSetWindowThemeAttribute: Pointer; 99 PoldThemeInitApiHook: Pointer; 100 PoldUpdatePanningFeedback: Pointer; 101 102 103 procedure BeginBufferedAnimation; 104 asm jmp PoldBeginBufferedAnimation 105 end; 106 108 procedure BeginBufferedPaint; 109 asm jmp PoldBeginBufferedPaint 110 end; 111 procedure BeginPanningFeedback; 112 asm jmp PoldBeginPanningFeedback 113 end; 114 115 116 procedure BufferedPaintClear; 117 asm jmp PoldBufferedPaintClear 118 end; 119 120 121 procedure BufferedPaintInit; 122 asm jmp PoldBufferedPaintInit 123 end; 124 125 126 procedure BufferedPaintRenderAnimation; 127 asm jmp PoldBufferedPaintRenderAnimation 128 end; 129 130 131 procedure BufferedPaintSetAlpha; 132 asm jmp PoldBufferedPaintSetAlpha 133 end; 134 135 136 procedure BufferedPaintStopAllAnimations; 137 asm jmp PoldBufferedPaintStopAllAnimations 138 end; 139 140 141 procedure BufferedPaintUnInit; 142 asm jmp PoldBufferedPaintUnInit 143 end; 144 145 146 procedure CloseThemeData; 147 asm jmp PoldCloseThemeData 148 end; 149 150 151 procedure DllCanUnloadNow; 152 asm jmp PoldDllCanUnloadNow 153 end; 154 155 156 procedure DllGetActivationFactory; 157 asm jmp PoldDllGetActivationFactory 158 end; 159 160 161 procedure DllGetClassObject; 162 asm jmp PoldDllGetClassObject 163 end; 164 165 166 procedure DrawThemeBackground; 167 asm jmp PoldDrawThemeBackground 168 end; 169 170 171 procedure DrawThemeBackgroundEx; 172 asm jmp PoldDrawThemeBackgroundEx 173 end; 174 procedure DrawThemeEdge; 175 asm jmp PoldDrawThemeEdge 176 end; 177 178 179 procedure DrawThemeIcon; 180 asm jmp PoldDrawThemeIcon 181 end; 182 183 184 procedure DrawThemeParentBackground; 185 asm jmp PoldDrawThemeParentBackground 186 end; 187 188 189 procedure DrawThemeParentBackgroundEx; 190 asm jmp PoldDrawThemeParentBackgroundEx 191 end; 192 193 194 procedure DrawThemeText; 195 asm jmp PoldDrawThemeText 196 end; 197 198 199 procedure DrawThemeTextEx; 200 asm jmp PoldDrawThemeTextEx 201 end; 202 procedure EnableThemeDialogTexture; 203 asm jmp PoldEnableThemeDialogTexture 204 end; 205 206 207 procedure EnableTheming; 208 asm jmp PoldEnableTheming 209 end; 210 211 212 procedure EndBufferedAnimation; 213 asm jmp PoldEndBufferedAnimation 214 end; 215 216 217 procedure EndBufferedPaint; 218 asm jmp PoldEndBufferedPaint 219 end; 220 221 222 procedure EndPanningFeedback; 223 asm jmp PoldEndPanningFeedback 224 end; 225 226 227 procedure GetBufferedPaintBits; 228 asm jmp PoldGetBufferedPaintBits 229 end; 230 231 232 procedure GetBufferedPaintDC; 233 asm jmp PoldGetBufferedPaintDC 234 end; 235 procedure GetBufferedPaintTargetDC; 236 asm jmp PoldGetBufferedPaintTargetDC 237 end; 238 procedure GetBufferedPaintTargetRect; 239 asm jmp PoldGetBufferedPaintTargetRect 240 end; 241 242 243 procedure GetColorFromPreference; 244 asm jmp PoldGetColorFromPreference 245 end; 246 247 248 procedure GetCurrentThemeName; 249 asm jmp PoldGetCurrentThemeName 250 end; 251 procedure GetImmersiveColorFromColorSetEx; 252 asm jmp PoldGetImmersiveColorFromColorSetEx 253 end; 254 procedure GetImmersiveUserColorSetPreference; 255 asm jmp PoldGetImmersiveUserColorSetPreference 256 end; 257 258 259 procedure GetThemeAnimationProperty; 260 asm jmp PoldGetThemeAnimationProperty 261 end; 262 263 264 procedure GetThemeAnimationTransform; 265 asm jmp PoldGetThemeAnimationTransform 266 end; 267 procedure GetThemeAppProperties; 268 asm jmp PoldGetThemeAppProperties 269 end; 270 271 272 procedure GetThemeBackgroundContentRect; 273 asm jmp PoldGetThemeBackgroundContentRect 274 end; 275 276 277 procedure GetThemeBackgroundExtent; 278 asm jmp PoldGetThemeBackgroundExtent 279 end; 280 281 282 procedure GetThemeBackgroundRegion; 283 asm jmp PoldGetThemeBackgroundRegion 284 end; 285 procedure GetThemeBitmap; 286 asm jmp PoldGetThemeBitmap 287 end; 288 289 290 procedure GetThemeBool; 291 asm jmp PoldGetThemeBool 292 end; 293 294 295 procedure GetThemeColor; 296 asm jmp PoldGetThemeColor 297 end; 298 299 300 procedure GetThemeDocumentationProperty; 301 asm jmp PoldGetThemeDocumentationProperty 302 end; 303 304 305 procedure GetThemeEnumValue; 306 asm jmp PoldGetThemeEnumValue 307 end; 308 309 310 procedure GetThemeFilename; 311 asm jmp PoldGetThemeFilename 312 end; 313 314 315 procedure GetThemeFont; 316 asm jmp PoldGetThemeFont 317 end; 318 procedure GetThemeInt; 319 asm jmp PoldGetThemeInt 320 end; 321 procedure GetThemeIntList; 322 asm jmp PoldGetThemeIntList 323 end; 324 procedure GetThemeMargins; 325 asm jmp PoldGetThemeMargins 326 end; 327 328 329 procedure GetThemeMetric; 330 asm jmp PoldGetThemeMetric 331 end; 332 333 334 procedure GetThemePartSize; 335 asm jmp PoldGetThemePartSize 336 end; 337 338 339 procedure GetThemePosition; 340 asm jmp PoldGetThemePosition 341 end; 342 343 344 procedure GetThemePropertyOrigin; 345 asm jmp PoldGetThemePropertyOrigin 346 end; 347 348 349 procedure GetThemeRect; 350 asm jmp PoldGetThemeRect 351 end; 352 353 354 procedure GetThemeStream; 355 asm jmp PoldGetThemeStream 356 end; 357 358 359 procedure GetThemeString; 360 asm jmp PoldGetThemeString 361 end; 362 363 364 procedure GetThemeSysBool; 365 asm jmp PoldGetThemeSysBool 366 end; 367 368 369 procedure GetThemeSysColor; 370 asm jmp PoldGetThemeSysColor 371 end; 372 373 374 procedure GetThemeSysColorBrush; 375 asm jmp PoldGetThemeSysColorBrush 376 end; 377 378 379 procedure GetThemeSysFont; 380 asm jmp PoldGetThemeSysFont 381 end; 382 383 384 procedure GetThemeSysInt; 385 asm jmp PoldGetThemeSysInt 386 end; 387 388 389 procedure GetThemeSysSize; 390 asm jmp PoldGetThemeSysSize 391 end; 392 393 394 procedure GetThemeSysString; 395 asm jmp PoldGetThemeSysString 396 end; 397 398 399 procedure GetThemeTextExtent; 400 asm jmp PoldGetThemeTextExtent 401 end; 402 403 404 procedure GetThemeTextMetrics; 405 asm jmp PoldGetThemeTextMetrics 406 end; 407 408 409 procedure GetThemeTimingFunction; 410 asm jmp PoldGetThemeTimingFunction 411 end; 412 413 414 procedure GetThemeTransitionDuration; 415 asm jmp PoldGetThemeTransitionDuration 416 end; 417 procedure GetUserColorPreference; 418 asm jmp PoldGetUserColorPreference 419 end; 420 procedure GetWindowTheme; 421 asm jmp PoldGetWindowTheme 422 end; 423 424 425 procedure HitTestThemeBackground; 426 asm jmp PoldHitTestThemeBackground 427 end; 428 429 430 procedure IsAppThemed; 431 asm jmp PoldIsAppThemed 432 end; 433 434 435 procedure IsCompositionActive; 436 asm jmp PoldIsCompositionActive 437 end; 438 439 440 procedure IsThemeActive; 441 asm jmp PoldIsThemeActive 442 end; 443 444 445 procedure IsThemeBackgroundPartiallyTransparent; 446 asm jmp PoldIsThemeBackgroundPartiallyTransparent 447 end; 448 449 450 procedure IsThemeDialogTextureEnabled; 451 asm jmp PoldIsThemeDialogTextureEnabled 452 end; 453 454 455 procedure IsThemePartDefined; 456 asm jmp PoldIsThemePartDefined 457 end; 458 459 460 procedure OpenThemeData; 461 asm jmp PoldOpenThemeData 462 end; 463 procedure OpenThemeDataEx; 464 asm jmp PoldOpenThemeDataEx 465 end; 466 467 468 procedure OpenThemeDataForDpi; 469 asm jmp PoldOpenThemeDataForDpi 470 end; 471 472 473 procedure SetThemeAppProperties; 474 asm jmp PoldSetThemeAppProperties 475 end; 476 procedure SetWindowTheme; 477 asm jmp PoldSetWindowTheme 478 end; 479 480 481 procedure SetWindowThemeAttribute; 482 asm jmp PoldSetWindowThemeAttribute