Gehts noch kleiner??
-
Hallo,
ich hhabe in c++ ein programm geschrieben das um die 30 registry werte in 6 ordnern speichert.das programm ist ohne RTTI 50 kb groß.mir war das zu viel also habe ich asm ausgepackt.das programm ist zwar nur noch 4kb groß aber das ist mir noch zu groß..ich WILL(!!!) 2kb..koste es was es wolle:-)das programm hat zwar den sinn verloren aber im moment gehts mir darum herauszufinden wo die grenzen von assembler sind.
Also meine frage.da ich ja die Offsets der funnktion RegSetValueExA und ein paar anderen funktionen aus der advapi32
brauche hab ich einfach die funktion GetProcAddress benutzt...jedoch will ich das vermeiden und die funktion direkt über den offset ansprechen..auf meinem system funktioniert das auch ganz gut aber wie sieht es da mit der kompatibilität zu anderen systemen aus??ist die offset adresse system gebunden und bei jedem anders oder auf allen win xp pro systemen gleich?
-
JA
-
Also ja sie ist immer gleich??
-
Nein. Die "ImageBase" im PE-Header einer DLL ist lediglich eine "Wunschadresse".
Kleiner Test :
ADVAPI32.RegSetValueExA : 0x77DAEBE7
-
ich weiss nicht genau was das programm noch so alles macht, aber die WINAPI funktionen sind in C geschriben, wenn dein programm also hauptsächlich aus denen besteht, dann kannst dus auch in C++ belassen
ich mein der größenunterschied ist prozentual nicht schlecht aber wenn das ganze nachher eh unter win xp laufen soll spielts doch keine rolle...
-
Okay,also das finde ich verwunderlich..bei mir ist der offset der funktion RegSetValueExA auch 77DAEBE7h
naja..naja das programm erstellt nur ein paar registry werte...am anfang hatte es nochh sinn aber im moment interessiert es mich einfach nur mal herauszufinden wo die grenzen des machbaren liegen..ich werd die tage mal den code reinstellen
RegCreateKeyExA ;77DAEAF4
RegSetValueExA ;77DAEBE7
RegCloseKey ;77DA6BF0hier nochmal ein paar offsets.
was ich aber merkwürdig fande war..also ich habe die GetProcAddress im kernel mit einem offset direkt angesprochen.ichh weiß außerdem das die advapi32.dll schon in den speicher geladen wurde aber wenn ich nun mit dem offset der RegCreateKeyExA funnktion einen key öffnen/erstellen will das schlägt das programm fehl und spuckt ne meldung aus sowas wie das der nicht aus speicher xyz lesen kann..wieso geht das beim kernel und da nicht..also damits alle verstehen..ich werd die tage mal ein paar screen shots vom IDE Disassembler reinstellen
-
secondsun@gmx.de schrieb:
das programm ist zwar nur noch 4kb groß aber das ist mir noch zu groß..ich WILL(!!!) 2kb..koste es was es wolle:-)das programm hat zwar den sinn verloren aber im moment gehts mir darum herauszufinden wo die grenzen von assembler sind.
Mit FASM kannst du ganz einfach Win32-Anwendungen schreiben, auch ohne die Adressen der WinAPI Funktionen zu kennen. Und solche Programme können auch 2kb klein sein, wenn du sparsam bist.
-
Also meine Programme in C sind nur 4kb groß. Ka wie du auf 50 kommst.
-
du könntest zudem noch einen shrinker drauf ansetzen
poste doch mal den source. man kann am "windows-konstrukt" immer mal ein paar byte sparen.
wenn alle stricke reissen kannste noch in der PE von hand bissken was pfuschen (ist dann aber offiziell keine windows-konforme executable, selbst wenn sie funktioniert).google müsste mir auch massenhaft was liefern wenn du nach shrinking-methoden für 4k intros suchst.
viel erfolg
-
So,da bin ich wieder...also..ich denk mal das es in c++ deswegen so groß ist weil ich es ohne diese laufzeitumgebung von borland compiliert habe..daran wirds liegen denn vorher war es erheblich kleiner:-( hätte mich auch gefreut wenns danach auch so klein geblieben wäre aber da das prog dann nur auf meinem rechner läuft wollte ich es ohne die runtime compilieren..und hier mal der asm code..also einige werte und schlüßelect sind doppelt..hab das programm ein bisschen umgeschrieben aber wenns mal im gebrauch ist dann werden die schlüssel wieder umbennent und das mytest wird dann durch richtige werte ersetzt..also bitte nicht wundern:
.586 .model flat, stdcall option casemap :none ; case sensitive ; ------------------------------------------------------------------------------------------------------------------------------------- include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc include \masm32\include\advapi32.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib includelib \masm32\lib\advapi32.lib .data szKeyName1 db "Software\Microsoft\Windows\CurrentVersion\MyTest" ,0 szKeyName2 db "Software\Microsoft\Windows\CurrentVersion\Explorer\MyTest" ,0 szKeyName3 db "Software\Microsoft\Windows\CurrentVersion\MyTMyTest" ,0 szKeyName5 db "Software\Micrsosoft\MyTest" ,0 szKeyName6 db "Software\Microsoft\Windows\CurrentVersion\MyTest" ,0 szKeyName7 db "Software\Microsoft\Windows NT\ CurrentVersion\MyTest" ,0 szKeyName8 db "SYSTEM\CurrentControlSet\Services\MyTest" ,0 szKeyName9 db "Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\MyTest" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- szDWValue1 db "MyTest1" ,0 szDWValue2 db "MyTest2" ,0 szDWValue3 db "MyTest3" ,0 szDWValue4 db "MyTest4" ,0 szDWValue5 db "MyTest5" ,0 szDWValue6 db "MyTest6" ,0 szDWValue7 db "MyTest7" ,0 szDWValue8 db "MyTest8" ,0 szDWValue9 db "MyTest9" ,0 szDWValue10 db "MyTest10" ,0 szDWValue11 db "MyTest11" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- szDWValue12 db "MyTest12" ,0 szDWValue13 db "MyTest13" ,0 szDWValue14 db "MyTest14" ,0 szDWValue15 db "MyTest15" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- szDWValue16 db "MyTest16" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- szDWValue17 db "MyTest17" ,0 szDWValue18 db "MyTest18" ,0 szDWValue19 db "MyTest19" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- szDWValue20 db "MyTest20" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- szDWValue21 db "MyTest21" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- szDWValue22 db "MyTest22" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- szDWValue23 db "MyTest23" ,0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- DubWord dd 1 DubWord2 dd 4 DubWord3 dd 0 StrWord1 db "0" ,0 StrWord2 db "100" ,0 DW_SIZE EQU 4 Disp dd 0 pKey dd 0 ; ------------------------------------------------------------------------------------------------------------------------------------------------------- .code start: invoke RegCreateKeyEx, HKEY_CURRENT_USER, ADDR szKeyName1, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ADDR pKey, ADDR Disp invoke RegSetValueEx, pKey, ADDR szDWValue1, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue2, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue3, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue4, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue5, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue6, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue7, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue8, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue9, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue10, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue11, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegCloseKey, pKey invoke RegCreateKeyEx, HKEY_CURRENT_USER, ADDR szKeyName2, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ADDR pKey, ADDR Disp invoke RegSetValueEx, pKey, ADDR szDWValue12, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue13, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue14, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegSetValueEx, pKey, ADDR szDWValue15, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegCloseKey, pKey invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE, ADDR szKeyName5, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ADDR pKey, ADDR Disp invoke RegSetValueEx, pKey, ADDR szDWValue17, NULL, REG_SZ, ADDR StrWord1, SIZEOF StrWord1 invoke RegSetValueEx, pKey, ADDR szDWValue18, NULL, REG_SZ, ADDR StrWord1, SIZEOF StrWord1 invoke RegSetValueEx, pKey, ADDR szDWValue19, NULL, REG_SZ, ADDR StrWord2, SIZEOF StrWord2 invoke RegCloseKey, pKey invoke RegCreateKeyEx, HKEY_CURRENT_USER, ADDR szKeyName6, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ADDR pKey, ADDR Disp invoke RegSetValueEx, pKey, ADDR szDWValue20, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegCloseKey, pKey invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE, ADDR szKeyName7, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ADDR pKey, ADDR Disp invoke RegSetValueEx, pKey, ADDR szDWValue21, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegCloseKey, pKey invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE, ADDR szKeyName8, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ADDR pKey, ADDR Disp invoke RegSetValueEx, pKey, ADDR szDWValue22, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord2, DW_SIZE invoke RegCloseKey, pKey invoke RegCreateKeyEx, HKEY_CURRENT_USER, ADDR szKeyName9, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ADDR pKey, ADDR Disp invoke RegSetValueEx, pKey, ADDR szDWValue23, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord3, DW_SIZE invoke RegCloseKey, pKey invoke RegCreateKeyEx, HKEY_LOCAL_MACHINE, ADDR szKeyName3, NULL, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, ADDR pKey, ADDR Disp invoke RegSetValueEx, pKey, ADDR szDWValue16, NULL, REG_DWORD_LITTLE_ENDIAN, ADDR DubWord, DW_SIZE invoke RegCloseKey, pKey invoke ExitProcess,NULL end start
das ganze habe ich mit masm32 geschrieben und raus kommen dann genau 4096Bytes....das ist mir zu viel..also habe ich mal meine ida angeworfen und das hier mal versucht ein wenig umzubauen:naja...schade..irgendwie finde ich die funktion nicht wo mamn bilder einfügen kann..ich txte es mal so...
.text:00401000 ; .text:00401000 ; +-------------------------------------------------------------------------+ .text:00401000 ; | This file is generated by The Interactive Disassembler (IDA) | .text:00401000 ; | Copyright (c) 2007 by DataRescue sa/nv, <ida@datarescue.com> | .text:00401000 ; | Evaluation version | .text:00401000 ; +-------------------------------------------------------------------------+ .text:00401000 ; .text:00401000 ; Input MD5 : 2D30B6539A2F1B32CB562A3F9033B91D .text:00401000 .text:00401000 ; File Name : D:\masm32\bin\Registry\MASM32\Registry_MASM32.exe .text:00401000 ; Format : Portable executable for 80386 (PE) .text:00401000 ; Imagebase : 400000 .text:00401000 ; Section 1. (virtual address 00001000) .text:00401000 ; Virtual size : 00000414 ( 1044.) .text:00401000 ; Section size in file : 00000600 ( 1536.) .text:00401000 ; Offset to raw data for section: 00000400 .text:00401000 ; Flags 60000020: Text Executable Readable .text:00401000 ; Alignment : default .text:00401000 .text:00401000 .686p .text:00401000 .mmx .text:00401000 .model flat .text:00401000 .text:00401000 ; =========================================================================== .text:00401000 .text:00401000 ; Segment type: Pure code .text:00401000 ; Segment permissions: Read/Execute .text:00401000 _text segment para public 'CODE' use32 .text:00401000 assume cs:_text .text:00401000 ;org 401000h .text:00401000 assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing .text:00401000 .text:00401000 ; =============== S U B R O U T I N E ======================================= .text:00401000 .text:00401000 .text:00401000 public start .text:00401000 start proc near .text:00401000 push offset dwDisposition ; lpdwDisposition .text:00401005 push offset phkResult ; phkResult .text:0040100A push 0 ; lpSecurityAttributes .text:0040100C push 0F003Fh ; samDesired .text:00401011 push 0 ; dwOptions .text:00401013 push 0 ; lpClass .text:00401015 push 0 ; Reserved .text:00401017 push offset SubKey ; "Software\\Microsoft\\Windows\\CurrentVersi"... .text:0040101C push 80000001h ; hKey .text:00401021 call RegCreateKeyExA .text:00401026 push 4 ; cbData .text:00401028 push offset Data ; lpData .text:0040102D push 4 ; dwType .text:0040102F push 0 ; Reserved .text:00401031 push offset ValueName ; "MyTest1" .text:00401036 push phkResult ; hKey .text:0040103C call RegSetValueExA .text:00401041 push 4 ; cbData .text:00401043 push offset Data ; lpData .text:00401048 push 4 ; dwType .text:0040104A push 0 ; Reserved .text:0040104C push offset aMytest2 ; "MyTest2" .text:00401051 push phkResult ; hKey .text:00401057 call RegSetValueExA .text:0040105C push 4 ; cbData .text:0040105E push offset Data ; lpData .text:00401063 push 4 ; dwType .text:00401065 push 0 ; Reserved .text:00401067 push offset aMytest3 ; "MyTest3" .text:0040106C push phkResult ; hKey .text:00401072 call RegSetValueExA .text:00401077 push 4 ; cbData .text:00401079 push offset Data ; lpData .text:0040107E push 4 ; dwType .text:00401080 push 0 ; Reserved .text:00401082 push offset aMytest4 ; "MyTest4" .text:00401087 push phkResult ; hKey .text:0040108D call RegSetValueExA .text:00401092 push 4 ; cbData .text:00401094 push offset Data ; lpData .text:00401099 push 4 ; dwType .text:0040109B push 0 ; Reserved .text:0040109D push offset aMytest5 ; "MyTest5" .text:004010A2 push phkResult ; hKey .text:004010A8 call RegSetValueExA .text:004010AD push 4 ; cbData .text:004010AF push offset Data ; lpData .text:004010B4 push 4 ; dwType .text:004010B6 push 0 ; Reserved .text:004010B8 push offset aMytest6 ; "MyTest6" .text:004010BD push phkResult ; hKey .text:004010C3 call RegSetValueExA .text:004010C8 push 4 ; cbData .text:004010CA push offset Data ; lpData .text:004010CF push 4 ; dwType .text:004010D1 push 0 ; Reserved .text:004010D3 push offset aMytest7 ; "MyTest7" .text:004010D8 push phkResult ; hKey .text:004010DE call RegSetValueExA .text:004010E3 push 4 ; cbData .text:004010E5 push offset Data ; lpData .text:004010EA push 4 ; dwType .text:004010EC push 0 ; Reserved .text:004010EE push offset aMytest8 ; "MyTest8" .text:004010F3 push phkResult ; hKey .text:004010F9 call RegSetValueExA .text:004010FE push 4 ; cbData .text:00401100 push offset Data ; lpData .text:00401105 push 4 ; dwType .text:00401107 push 0 ; Reserved .text:00401109 push offset aMytest9 ; "MyTest9" .text:0040110E push phkResult ; hKey .text:00401114 call RegSetValueExA .text:00401119 push 4 ; cbData .text:0040111B push offset Data ; lpData .text:00401120 push 4 ; dwType .text:00401122 push 0 ; Reserved .text:00401124 push offset aMytest10 ; "MyTest10" .text:00401129 push phkResult ; hKey .text:0040112F call RegSetValueExA .text:00401134 push 4 ; cbData .text:00401136 push offset Data ; lpData .text:0040113B push 4 ; dwType .text:0040113D push 0 ; Reserved .text:0040113F push offset aMytest11 ; "MyTest11" .text:00401144 push phkResult ; hKey .text:0040114A call RegSetValueExA .text:0040114F push phkResult ; hKey .text:00401155 call RegCloseKey .text:0040115A push offset dwDisposition ; lpdwDisposition .text:0040115F push offset phkResult ; phkResult .text:00401164 push 0 ; lpSecurityAttributes .text:00401166 push 0F003Fh ; samDesired .text:0040116B push 0 ; dwOptions .text:0040116D push 0 ; lpClass .text:0040116F push 0 ; Reserved .text:00401171 push offset aSoftwareMicr_0 ; "Software\\Microsoft\\Windows\\CurrentVersi"... .text:00401176 push 80000001h ; hKey .text:0040117B call RegCreateKeyExA .text:00401180 push 4 ; cbData .text:00401182 push offset Data ; lpData .text:00401187 push 4 ; dwType .text:00401189 push 0 ; Reserved .text:0040118B push offset aMytest12 ; "MyTest12" .text:00401190 push phkResult ; hKey .text:00401196 call RegSetValueExA .text:0040119B push 4 ; cbData .text:0040119D push offset Data ; lpData .text:004011A2 push 4 ; dwType .text:004011A4 push 0 ; Reserved .text:004011A6 push offset aMytest13 ; "MyTest13" .text:004011AB push phkResult ; hKey .text:004011B1 call RegSetValueExA .text:004011B6 push 4 ; cbData .text:004011B8 push offset Data ; lpData .text:004011BD push 4 ; dwType .text:004011BF push 0 ; Reserved .text:004011C1 push offset aMytest14 ; "MyTest14" .text:004011C6 push phkResult ; hKey .text:004011CC call RegSetValueExA .text:004011D1 push 4 ; cbData .text:004011D3 push offset Data ; lpData .text:004011D8 push 4 ; dwType .text:004011DA push 0 ; Reserved .text:004011DC push offset aMytest15 ; "MyTest15" .text:004011E1 push phkResult ; hKey .text:004011E7 call RegSetValueExA .text:004011EC push phkResult ; hKey .text:004011F2 call RegCloseKey .text:004011F7 push offset dwDisposition ; lpdwDisposition .text:004011FC push offset phkResult ; phkResult .text:00401201 push 0 ; lpSecurityAttributes .text:00401203 push 0F003Fh ; samDesired .text:00401208 push 0 ; dwOptions .text:0040120A push 0 ; lpClass .text:0040120C push 0 ; Reserved .text:0040120E push offset aSoftwareMicrso ; "Software\\Micrsosoft\\MyTest" .text:00401213 push 80000002h ; hKey .text:00401218 call RegCreateKeyExA .text:0040121D push 2 ; cbData .text:0040121F push offset byte_40325E ; lpData .text:00401224 push 1 ; dwType .text:00401226 push 0 ; Reserved .text:00401228 push offset aMytest17 ; "MyTest17" .text:0040122D push phkResult ; hKey .text:00401233 call RegSetValueExA .text:00401238 push 2 ; cbData .text:0040123A push offset byte_40325E ; lpData .text:0040123F push 1 ; dwType .text:00401241 push 0 ; Reserved .text:00401243 push offset aMytest18 ; "MyTest18" .text:00401248 push phkResult ; hKey .text:0040124E call RegSetValueExA .text:00401253 push 4 ; cbData .text:00401255 push offset byte_403260 ; lpData .text:0040125A push 1 ; dwType .text:0040125C push 0 ; Reserved .text:0040125E push offset aMytest19 ; "MyTest19" .text:00401263 push phkResult ; hKey .text:00401269 call RegSetValueExA .text:0040126E push phkResult ; hKey .text:00401274 call RegCloseKey .text:00401279 push offset dwDisposition ; lpdwDisposition .text:0040127E push offset phkResult ; phkResult .text:00401283 push 0 ; lpSecurityAttributes .text:00401285 push 0F003Fh ; samDesired .text:0040128A push 0 ; dwOptions .text:0040128C push 0 ; lpClass .text:0040128E push 0 ; Reserved .text:00401290 push offset aSoftwareMicr_1 ; "Software\\Microsoft\\Windows\\CurrentVersi"... .text:00401295 push 80000001h ; hKey .text:0040129A call RegCreateKeyExA .text:0040129F push 4 ; cbData .text:004012A1 push offset Data ; lpData .text:004012A6 push 4 ; dwType .text:004012A8 push 0 ; Reserved .text:004012AA push offset aMytest20 ; "MyTest20" .text:004012AF push phkResult ; hKey .text:004012B5 call RegSetValueExA .text:004012BA push phkResult ; hKey .text:004012C0 call RegCloseKey .text:004012C5 push offset dwDisposition ; lpdwDisposition .text:004012CA push offset phkResult ; phkResult .text:004012CF push 0 ; lpSecurityAttributes .text:004012D1 push 0F003Fh ; samDesired .text:004012D6 push 0 ; dwOptions .text:004012D8 push 0 ; lpClass .text:004012DA push 0 ; Reserved .text:004012DC push offset aSoftwareMicr_2 ; "Software\\Microsoft\\Windows NT\\ CurrentV"... .text:004012E1 push 80000002h ; hKey .text:004012E6 call RegCreateKeyExA .text:004012EB push 4 ; cbData .text:004012ED push offset Data ; lpData .text:004012F2 push 4 ; dwType .text:004012F4 push 0 ; Reserved .text:004012F6 push offset aMytest21 ; "MyTest21" .text:004012FB push phkResult ; hKey .text:00401301 call RegSetValueExA .text:00401306 push phkResult ; hKey .text:0040130C call RegCloseKey .text:00401311 push offset dwDisposition ; lpdwDisposition .text:00401316 push offset phkResult ; phkResult .text:0040131B push 0 ; lpSecurityAttributes .text:0040131D push 0F003Fh ; samDesired .text:00401322 push 0 ; dwOptions .text:00401324 push 0 ; lpClass .text:00401326 push 0 ; Reserved .text:00401328 push offset aSystemCurrentc ; "SYSTEM\\CurrentControlSet\\Services\\MyTes"... .text:0040132D push 80000002h ; hKey .text:00401332 call RegCreateKeyExA .text:00401337 push 4 ; cbData .text:00401339 push offset byte_403256 ; lpData .text:0040133E push 4 ; dwType .text:00401340 push 0 ; Reserved .text:00401342 push offset aMytest22 ; "MyTest22" .text:00401347 push phkResult ; hKey .text:0040134D call RegSetValueExA .text:00401352 push phkResult ; hKey .text:00401358 call RegCloseKey .text:0040135D push offset dwDisposition ; lpdwDisposition .text:00401362 push offset phkResult ; phkResult .text:00401367 push 0 ; lpSecurityAttributes .text:00401369 push 0F003Fh ; samDesired .text:0040136E push 0 ; dwOptions .text:00401370 push 0 ; lpClass .text:00401372 push 0 ; Reserved .text:00401374 push offset aSoftwareMicr_3 ; "Software\\Microsoft\\Windows\\CurrentVersi"... .text:00401379 push 80000001h ; hKey .text:0040137E call RegCreateKeyExA .text:00401383 push 4 ; cbData .text:00401385 push offset byte_40325A ; lpData .text:0040138A push 4 ; dwType .text:0040138C push 0 ; Reserved .text:0040138E push offset aMytest23 ; "MyTest23" .text:00401393 push phkResult ; hKey .text:00401399 call RegSetValueExA .text:0040139E push phkResult ; hKey .text:004013A4 call RegCloseKey .text:004013A9 push offset dwDisposition ; lpdwDisposition .text:004013AE push offset phkResult ; phkResult .text:004013B3 push 0 ; lpSecurityAttributes .text:004013B5 push 0F003Fh ; samDesired .text:004013BA push 0 ; dwOptions .text:004013BC push 0 ; lpClass .text:004013BE push 0 ; Reserved .text:004013C0 push offset aSoftwareMicr_4 ; "Software\\Microsoft\\Windows\\CurrentVersi"... .text:004013C5 push 80000002h ; hKey .text:004013CA call RegCreateKeyExA .text:004013CF push 4 ; cbData .text:004013D1 push offset Data ; lpData .text:004013D6 push 4 ; dwType .text:004013D8 push 0 ; Reserved .text:004013DA push offset aMytest16 ; "MyTest16" .text:004013DF push phkResult ; hKey .text:004013E5 call RegSetValueExA .text:004013EA push phkResult ; hKey .text:004013F0 call RegCloseKey .text:004013F5 push 0 .text:004013F7 call $+5 .text:004013FC jmp ds:ExitProcess .text:004013FC start endp .text:004013FC .text:00401402 ; [00000006 BYTES: COLLAPSED FUNCTION RegCloseKey. PRESS KEYPAD "+" TO EXPAND] .text:00401408 ; [00000006 BYTES: COLLAPSED FUNCTION RegCreateKeyExA. PRESS KEYPAD "+" TO EXPAND] .text:0040140E ; [00000006 BYTES: COLLAPSED FUNCTION RegSetValueExA. PRESS KEYPAD "+" TO EXPAND] .text:00401414 align 200h .text:00401414 _text ends .text:00401414 .idata:00402000 ; Section 2. (virtual address 00002000) .idata:00402000 ; Virtual size : 000000C8 ( 200.) .idata:00402000 ; Section size in file : 00000200 ( 512.) .idata:00402000 ; Offset to raw data for section: 00000A00 .idata:00402000 ; Flags 40000040: Data Readable .idata:00402000 ; Alignment : default .idata:00402000 ; .idata:00402000 ; Imports from advapi32.dll .idata:00402000 ; .idata:00402000 ; =========================================================================== .idata:00402000 .idata:00402000 ; Segment type: Externs .idata:00402000 ; _idata .idata:00402000 ; LSTATUS __stdcall RegSetValueExA(HKEY hKey,LPCSTR lpValueName,DWORD Reserved,DWORD dwType,const BYTE *lpData,DWORD cbData) .idata:00402000 extrn __imp_RegSetValueExA:dword .idata:00402000 ; DATA XREF: RegSetValueExAr .idata:00402004 ; LSTATUS __stdcall RegCloseKey(HKEY hKey) .idata:00402004 extrn __imp_RegCloseKey:dword ; DATA XREF: RegCloseKeyr .idata:00402008 ; LSTATUS __stdcall RegCreateKeyExA(HKEY hKey,LPCSTR lpSubKey,DWORD Reserved,LPSTR lpClass,DWORD dwOptions,REGSAM samDesired,const LPSECURITY_ATTRIBUTES lpSecurityAttributes,PHKEY phkResult,LPDWORD lpdwDisposition) .idata:00402008 extrn __imp_RegCreateKeyExA:dword .idata:00402008 ; DATA XREF: RegCreateKeyExAr .idata:0040200C .idata:00402010 ; .idata:00402010 ; Imports from kernel32.dll .idata:00402010 ; .idata:00402010 ; void __stdcall ExitProcess(UINT uExitCode) .idata:00402010 extrn ExitProcess:dword ; DATA XREF: start+3FCr .idata:00402010 .rdata:00402014 ; ===========================================================================
ups...das ist ja mehr als ich dachte..aber egal...
so jetzt dachte ich mir das man schon mal die drei funktionen die mit der registry arbeiten als funktion aufrufen könnte..nur weiß ich nich tob das sinn machen würde..denn immer einen call dazwischen zu bauen..ich hab nämlich keine ahnung inwiefern ein call platz belegt..aber die funktion close key zum bleistift ist für mich nicht so das problem sondern ehr wie man am besten eine funktion schreibt die z.b
diese hier ersetzt:push 4 ; cbData .text:00401028 push offset Data ; lpData .text:0040102D push 4 ; dwType .text:0040102F push 0 ; Reserved .text:00401031 push offset ValueName ; "MyTest1" .text:00401036 push phkResult ; hKey .text:0040103C call RegSetValueExA
ich dachte da eine push der data und valuename direkt hintereinander auf den stack schmeißt und dann einen call zu der funktion die dann den rest pusht...versteht ihr??
-
okay,ich habe mir gerad upx heruntergeladen und er besorgt es mir so richtig:-) ich bin jetzt von 4096 auf 2560 bytes runtergekommen..ich werde aber bei zeiten nooch den fasm ausprobieren...
-
Warum verzichtest du nicht einfach auf die Standardbiblio? Dann kannst du weiter in C programmieren, bist von keinen Dlls abhängig und dein Prog ist nur 4kb groß.
-
Ich will keine 4kb..ich willl 2 kb...DAS habe ich mir als ziel gesetzt:-)
-
wieviel kb muss eine exe denn mindestens haben?
-
Es gibt eigentlich keine Mindestgröße für PE-Dateien. Die normale Größe für Segmente beträgt aber 512 Byte. Und ein Segment (Codesegment) braucht man für eine funktionierende Datei mindestens. Dazu kommt noch ein Header von einige Bytes. Also meine kleinste Datei, die eine MessageBox anzeigt war etwas über 600 Bytes wobei ich nicht sehr lange daran saß.
Wenn man entsprechend viele Tricks anwendet lässt sich da noch eine Menge rausholen. Dies ist einer netter Artikel zu dem Thema: http://www.phreedom.org/solar/code/tinype/. Die kleinste PE Datei, die der Autor dort zustande bringt ist tatsächlich nur 97 Bytes groß. Die Datei kann natürlich auch entsprechend wenig (gibt 42 zurück). Aber die Größe ist echt beeindruckend.
-
ich würde dir mal ne schleife empfehlen...