└── narly ├── ChangeLog.txt ├── ReadMe.txt ├── dll_all ├── dll_all.cpp ├── dll_all.h ├── dll_all.vcxproj ├── dll_all.vcxproj.filters └── dll_all.vcxproj.user ├── dll_safeseh_gs ├── dll_safeseh_gs.cpp ├── dll_safeseh_gs.h ├── dll_safeseh_gs.vcxproj ├── dll_safeseh_gs.vcxproj.filters └── dll_safeseh_gs.vcxproj.user ├── dll_seh_aslr ├── dll_seh_aslr.cpp ├── dll_seh_aslr.h ├── dll_seh_aslr.vcxproj ├── dll_seh_aslr.vcxproj.filters └── dll_seh_aslr.vcxproj.user ├── dll_seh_dep ├── dll_seh_dep.cpp ├── dll_seh_dep.h ├── dll_seh_dep.vcxproj ├── dll_seh_dep.vcxproj.filters └── dll_seh_dep.vcxproj.user ├── narly.cpp ├── narly.def ├── narly.h ├── narly.sln ├── narly.vcproj ├── narly.vcxproj ├── narly.vcxproj.filters ├── narly.vcxproj.user ├── narly_tester ├── narly_tester.cpp ├── narly_tester.vcxproj ├── narly_tester.vcxproj.filters ├── narly_tester.vcxproj.user ├── stdafx.cpp ├── stdafx.h └── targetver.h ├── stdafx.cpp ├── stdafx.h ├── targetver.h └── tokenizer.h /narly/ChangeLog.txt: -------------------------------------------------------------------------------- 1 | 06/29/2011 2 | ---------- 3 | * [issue 3] narly can now be built for x64 platforms 4 | 5 | 03/25/2011 6 | ---------- 7 | * [issue 1] compiler option added to make narly.dll independent of msvcrt90.dll -------------------------------------------------------------------------------- /narly/ReadMe.txt: -------------------------------------------------------------------------------- 1 | This windbg extension is intended to be able to: 2 | 3 | * list /SafeSEH, /GS, DEP, and ASLR info about all loaded modules 4 | * search for ROP gadgets 5 | * other misc utils 6 | 7 | Currently, only listing info about loaded modules is implemented. It will probably be worth 8 | it to check back every now and then for a new release, as a lot is currently in the works. You 9 | may also ping me directly to see if anything new is on its way. Also, if you find a bug with 10 | this extension, please file a bug at https://code.google.com/p/narly/issues. In case you 11 | can't file a bug (permissions error or something), ping me. 12 | 13 | Example: 14 | 15 | To "install", copy narly.dll into the winext folder for windbg. The path to the winext folder 16 | usually looks something like this: 17 | 18 | C:\Program Files\Debugging Tools for Windows (x86)\winext 19 | 20 | After you do that, you can .load narly to load the extension into windbg: 21 | 22 | 0:018> .load narly 23 | 24 | __s|I}*!{a. ._s,aan2*a 25 | _wY1+~- )S, .ae"~=:...:X 26 | .vXl+:. -4c <2+=|==::..:d 27 | vvi=;.. -?o, =2=+==:::...=d 28 | )nv=:. )5, .2=--.......-=d 29 | ue+:: -*s ==::.. ._, )2d 34 | X=)vvvvIliii:3; -!s. :)s. )e.-{%i. )c==-. :o` "1,:+iI,)c:Sonnvli||=v( 39 | X>{ii+;:- .u( "o,-{Iw(:nvvvllii=v2 40 | S=i||;:. .=u( -!o,+I(:iiillii|ie` 41 | 2>v|==__su?` -?o,-:==||iisv" 42 | {nvnI!""~ -!sasvv}""` 43 | 44 | by Nephi Johnson (d0c_s4vage) 45 | N for gnarly! 46 | 47 | Available commands: 48 | 49 | !nmod - display /SafeSEH, /GS, DEP, and ASLR info for 50 | all loaded modules 51 | 52 | 0:018> !nmod /help 53 | Summary: 54 | 55 | !nmod lists all of the loaded and unloaded modules, displaying 56 | info on /SafeSEH, NO_SEH, /GS, and ASLR and DEP compatibility 57 | 58 | Usage: !nmod [/v /help] 59 | 60 | /debug - Display verbose output 61 | /verbose 62 | /v 63 | 64 | help - Who knows what this might do. I wouldn't try it if 65 | /? I were you though. 66 | 0:018> !nmod 67 | 00400000 0049c000 IEXPLORE /SafeSEH ON /GS *ASLR C:\Program Files\Internet Explorer\IEXPLORE.EXE 68 | 010c0000 010c9000 Normaliz /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\Normaliz.dll 69 | 022d0000 022f9000 msls31 /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\msls31.dll 70 | 1b000000 1b00c000 ImgUtil /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\ImgUtil.dll 71 | 1b060000 1b06e000 pngfilt /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\pngfilt.dll 72 | 20000000 202c5000 xpsp2res NO_SEH C:\WINDOWS\system32\xpsp2res.dll 73 | 3cea0000 3d450000 mshtml /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\mshtml.dll 74 | 3d930000 3da16000 WININET /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\WININET.dll 75 | 3dfd0000 3e1b8000 iertutil /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\iertutil.dll 76 | 3e1c0000 3ec54000 IEFRAME /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\IEFRAME.dll 77 | 42070000 4209f000 iepeers /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\iepeers.dll 78 | 439b0000 439f0000 ieproxy /SafeSEH ON /GS *ASLR *DEP C:\Program Files\Internet Explorer\ieproxy.dll 79 | 451f0000 451f6000 xpshims /SafeSEH ON /GS *ASLR *DEP C:\Program Files\Internet Explorer\xpshims.dll 80 | 5ad70000 5ada8000 uxtheme /SafeSEH ON /GS C:\WINDOWS\system32\uxtheme.dll 81 | 5b860000 5b8b4000 NETAPI32 /SafeSEH ON /GS C:\WINDOWS\system32\NETAPI32.dll 82 | 5d090000 5d127000 comctl32_5d090000 /SafeSEH ON /GS C:\WINDOWS\system32\comctl32.dll 83 | 606b0000 607bd000 ESENT /SafeSEH ON /GS C:\WINDOWS\system32\ESENT.dll 84 | 63380000 63434000 jscript /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\System32\jscript.dll 85 | 662b0000 66308000 hnetcfg /SafeSEH ON /GS C:\WINDOWS\system32\hnetcfg.dll 86 | 6d440000 6d44c000 jp2ssv /SafeSEH ON /GS C:\Program Files\Java\jre6\bin\jp2ssv.dll 87 | 6dae0000 6daf2000 jqs_plugin /SafeSEH ON /GS C:\Program Files\Java\jre6\lib\deploy\jqs\ie\jqs_plugin.dll 88 | 71a50000 71a8f000 mswsock /SafeSEH ON /GS C:\WINDOWS\System32\mswsock.dll 89 | 71a90000 71a98000 wshtcpip /SafeSEH ON /GS C:\WINDOWS\System32\wshtcpip.dll 90 | 71aa0000 71aa8000 WS2HELP /SafeSEH ON /GS C:\WINDOWS\system32\WS2HELP.dll 91 | 71ab0000 71ac7000 ws2_32 /SafeSEH ON /GS C:\WINDOWS\system32\ws2_32.dll 92 | 71bf0000 71c03000 SAMLIB /SafeSEH ON /GS C:\WINDOWS\system32\SAMLIB.dll 93 | 71d40000 71d5c000 actxprxy NO_SEH C:\WINDOWS\system32\actxprxy.dll 94 | 722b0000 722b5000 sensapi NO_SEH C:\WINDOWS\system32\sensapi.dll 95 | 73000000 73026000 WINSPOOL /SafeSEH ON /GS C:\WINDOWS\system32\WINSPOOL.DRV 96 | 73030000 73040000 WZCSAPI /SafeSEH ON /GS C:\WINDOWS\system32\WZCSAPI.DLL 97 | 746f0000 7471a000 msimtf NO_SEH C:\WINDOWS\System32\msimtf.dll 98 | 74720000 7476b000 MSCTF /SafeSEH ON /GS C:\WINDOWS\system32\MSCTF.dll 99 | 755c0000 755ee000 msctfime /SafeSEH ON /GS C:\WINDOWS\system32\msctfime.ime 100 | 75cf0000 75d81000 MLANG /SafeSEH ON /GS C:\WINDOWS\system32\MLANG.dll 101 | 75e90000 75f40000 SXS /SafeSEH ON /GS C:\WINDOWS\system32\SXS.DLL 102 | 76360000 76370000 WINSTA /SafeSEH ON /GS C:\WINDOWS\system32\WINSTA.dll 103 | 76380000 76385000 msimg32 NO_SEH C:\WINDOWS\system32\msimg32.dll 104 | 76390000 763ad000 IMM32 /SafeSEH ON /GS C:\WINDOWS\system32\IMM32.DLL 105 | 763b0000 763f9000 comdlg32 /SafeSEH ON /GS C:\WINDOWS\system32\comdlg32.dll 106 | 76400000 765a6000 netshell /SafeSEH ON /GS C:\WINDOWS\system32\netshell.dll 107 | 769c0000 76a73000 USERENV /SafeSEH ON /GS C:\WINDOWS\system32\USERENV.dll 108 | 76b20000 76b31000 ATL NO_SEH C:\WINDOWS\system32\ATL.DLL 109 | 76b40000 76b6d000 WINMM /SafeSEH ON /GS C:\WINDOWS\system32\WINMM.dll 110 | 76bf0000 76bfb000 PSAPI /SafeSEH ON /GS C:\WINDOWS\system32\PSAPI.DLL 111 | 76c00000 76c2e000 credui /SafeSEH ON /GS C:\WINDOWS\system32\credui.dll 112 | 76d30000 76d34000 WMI NO_SEH C:\WINDOWS\system32\WMI.dll 113 | 76d40000 76d58000 MPRAPI /SafeSEH ON /GS C:\WINDOWS\system32\MPRAPI.dll 114 | 76d60000 76d79000 iphlpapi /SafeSEH ON /GS C:\WINDOWS\system32\iphlpapi.dll 115 | 76d80000 76d9e000 DHCPCSVC /SafeSEH ON /GS C:\WINDOWS\system32\DHCPCSVC.DLL 116 | 76e10000 76e35000 adsldpc /SafeSEH ON /GS C:\WINDOWS\system32\adsldpc.dll 117 | 76e80000 76e8e000 rtutils /SafeSEH ON /GS C:\WINDOWS\system32\rtutils.dll 118 | 76e90000 76ea2000 rasman /SafeSEH ON /GS C:\WINDOWS\system32\rasman.dll 119 | 76eb0000 76edf000 TAPI32 /SafeSEH ON /GS C:\WINDOWS\system32\TAPI32.dll 120 | 76ee0000 76f1c000 RASAPI32 /SafeSEH ON /GS C:\WINDOWS\system32\RASAPI32.dll 121 | 76f20000 76f47000 DNSAPI /SafeSEH ON /GS C:\WINDOWS\system32\DNSAPI.dll 122 | 76f50000 76f58000 WTSAPI32 NO_SEH C:\WINDOWS\system32\WTSAPI32.dll 123 | 76f60000 76f8c000 WLDAP32 /SafeSEH ON /GS C:\WINDOWS\system32\WLDAP32.dll 124 | 76fc0000 76fc6000 rasadhlp NO_SEH C:\WINDOWS\system32\rasadhlp.dll 125 | 76fd0000 7704f000 CLBCATQ /SafeSEH ON /GS C:\WINDOWS\system32\CLBCATQ.DLL 126 | 77050000 77115000 COMRes NO_SEH C:\WINDOWS\system32\COMRes.dll 127 | 77120000 771ac000 OLEAUT32 /SafeSEH ON /GS C:\WINDOWS\system32\OLEAUT32.dll 128 | 773d0000 774d2000 comctl32 /SafeSEH ON /GS C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2180_x-ww_a84f1ff9\comctl32.dll 129 | 774e0000 7761c000 ole32 /SafeSEH ON /GS C:\WINDOWS\system32\ole32.dll 130 | 77620000 7768e000 WZCSvc /SafeSEH ON /GS C:\WINDOWS\system32\WZCSvc.DLL 131 | 77920000 77a13000 SETUPAPI /SafeSEH ON /GS C:\WINDOWS\system32\SETUPAPI.dll 132 | 77a80000 77b14000 CRYPT32 /SafeSEH ON /GS C:\WINDOWS\system32\CRYPT32.dll 133 | 77b20000 77b32000 MSASN1 NO_SEH C:\WINDOWS\system32\MSASN1.dll 134 | 77b40000 77b62000 appHelp /SafeSEH ON /GS C:\WINDOWS\system32\appHelp.dll 135 | 77c00000 77c08000 VERSION /SafeSEH ON /GS C:\WINDOWS\system32\VERSION.dll 136 | 77c10000 77c68000 msvcrt /SafeSEH ON /GS C:\WINDOWS\system32\msvcrt.dll 137 | 77c70000 77c93000 msv1_0 /SafeSEH ON /GS C:\WINDOWS\system32\msv1_0.dll 138 | 77cc0000 77cf2000 ACTIVEDS /SafeSEH ON /GS C:\WINDOWS\system32\ACTIVEDS.dll 139 | 77d00000 77d33000 netman /SafeSEH ON /GS C:\WINDOWS\system32\netman.dll 140 | 77d40000 77dd0000 USER32 /SafeSEH ON /GS C:\WINDOWS\system32\USER32.dll 141 | 77dd0000 77e6b000 ADVAPI32 /SafeSEH ON /GS C:\WINDOWS\system32\ADVAPI32.dll 142 | 77e70000 77f01000 RPCRT4 /SafeSEH ON /GS C:\WINDOWS\system32\RPCRT4.dll 143 | 77f10000 77f56000 GDI32 /SafeSEH ON /GS C:\WINDOWS\system32\GDI32.dll 144 | 77f60000 77fd6000 SHLWAPI /SafeSEH ON /GS C:\WINDOWS\system32\SHLWAPI.dll 145 | 77fe0000 77ff1000 Secur32 /SafeSEH ON /GS C:\WINDOWS\system32\Secur32.dll 146 | 78130000 78263000 urlmon /SafeSEH ON /GS *ASLR *DEP C:\WINDOWS\system32\urlmon.dll 147 | 7c340000 7c396000 MSVCR71 /SafeSEH ON /GS C:\Program Files\Java\jre6\bin\MSVCR71.dll 148 | 7c800000 7c8f4000 kernel32 /SafeSEH ON /GS C:\WINDOWS\system32\kernel32.dll 149 | 7c900000 7c9b0000 ntdll /SafeSEH ON C:\WINDOWS\system32\ntdll.dll 150 | 7c9c0000 7d1d4000 SHELL32 /SafeSEH ON /GS C:\WINDOWS\system32\SHELL32.dll 151 | 152 | Unloaded modules: 153 | 6cd00000 6cd00000 sqmapi.dll 154 | 155 | *DEP/*ASLR means that these modules are compatible with ASLR/DEP -------------------------------------------------------------------------------- /narly/dll_all/dll_all.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "dll_all.h" 3 | 4 | namespace narly_testing { 5 | char * All::A() { 6 | return "safeseh dep aslr gs"; 7 | }; 8 | } -------------------------------------------------------------------------------- /narly/dll_all/dll_all.h: -------------------------------------------------------------------------------- 1 | 2 | namespace narly_testing { 3 | class All { 4 | public: 5 | static __declspec(dllexport) char *A(); 6 | }; 7 | } -------------------------------------------------------------------------------- /narly/dll_all/dll_all.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {656B519A-289D-4803-B9A5-98D0F034DC03} 23 | Win32Proj 24 | dll_all 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | Unicode 31 | 32 | 33 | DynamicLibrary 34 | true 35 | Unicode 36 | 37 | 38 | DynamicLibrary 39 | false 40 | true 41 | MultiByte 42 | Static 43 | 44 | 45 | DynamicLibrary 46 | false 47 | true 48 | MultiByte 49 | Static 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | true 69 | 70 | 71 | true 72 | 73 | 74 | false 75 | 76 | 77 | false 78 | 79 | 80 | 81 | 82 | 83 | Level3 84 | Disabled 85 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_ALL_EXPORTS;%(PreprocessorDefinitions) 86 | 87 | 88 | Windows 89 | true 90 | 91 | 92 | 93 | 94 | 95 | 96 | Level3 97 | Disabled 98 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_ALL_EXPORTS;%(PreprocessorDefinitions) 99 | 100 | 101 | Windows 102 | true 103 | 104 | 105 | 106 | 107 | Level3 108 | 109 | 110 | MaxSpeed 111 | true 112 | true 113 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_ALL_EXPORTS;%(PreprocessorDefinitions) 114 | 115 | 116 | Windows 117 | true 118 | true 119 | true 120 | true 121 | 122 | 123 | 124 | 125 | Level3 126 | 127 | 128 | MaxSpeed 129 | true 130 | true 131 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_ALL_EXPORTS;%(PreprocessorDefinitions) 132 | 133 | 134 | Windows 135 | true 136 | true 137 | true 138 | true 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /narly/dll_all/dll_all.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /narly/dll_all/dll_all.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /narly/dll_safeseh_gs/dll_safeseh_gs.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "dll_safeseh_gs.h" 3 | 4 | namespace narly_testing { 5 | char * SafeSehGs::A() { 6 | return "safeseh gs"; 7 | }; 8 | } -------------------------------------------------------------------------------- /narly/dll_safeseh_gs/dll_safeseh_gs.h: -------------------------------------------------------------------------------- 1 | 2 | namespace narly_testing { 3 | class SafeSehGs { 4 | public: 5 | static __declspec(dllexport) char *A(); 6 | }; 7 | } -------------------------------------------------------------------------------- /narly/dll_safeseh_gs/dll_safeseh_gs.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {E2630795-74BC-431C-B71C-1E8BA3457126} 23 | Win32Proj 24 | dll_safeseh_gs 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | Unicode 31 | 32 | 33 | DynamicLibrary 34 | true 35 | Unicode 36 | 37 | 38 | DynamicLibrary 39 | false 40 | true 41 | MultiByte 42 | Static 43 | 44 | 45 | DynamicLibrary 46 | false 47 | true 48 | MultiByte 49 | Static 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | true 69 | 70 | 71 | true 72 | 73 | 74 | false 75 | 76 | 77 | false 78 | 79 | 80 | 81 | 82 | 83 | Level3 84 | Disabled 85 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_SAFESEH_GS_EXPORTS;%(PreprocessorDefinitions) 86 | 87 | 88 | Windows 89 | true 90 | 91 | 92 | 93 | 94 | 95 | 96 | Level3 97 | Disabled 98 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_SAFESEH_GS_EXPORTS;%(PreprocessorDefinitions) 99 | 100 | 101 | Windows 102 | true 103 | 104 | 105 | 106 | 107 | Level3 108 | 109 | 110 | MaxSpeed 111 | true 112 | true 113 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_SAFESEH_GS_EXPORTS;%(PreprocessorDefinitions) 114 | 115 | 116 | Windows 117 | true 118 | true 119 | true 120 | false 121 | false 122 | true 123 | 124 | 125 | 126 | 127 | Level3 128 | 129 | 130 | MaxSpeed 131 | true 132 | true 133 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_SAFESEH_GS_EXPORTS;%(PreprocessorDefinitions) 134 | 135 | 136 | Windows 137 | true 138 | true 139 | true 140 | false 141 | false 142 | true 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /narly/dll_safeseh_gs/dll_safeseh_gs.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /narly/dll_safeseh_gs/dll_safeseh_gs.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /narly/dll_seh_aslr/dll_seh_aslr.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "dll_seh_aslr.h" 3 | 4 | namespace narly_testing { 5 | char * SehAslr::A() { 6 | return "seh aslr"; 7 | }; 8 | } -------------------------------------------------------------------------------- /narly/dll_seh_aslr/dll_seh_aslr.h: -------------------------------------------------------------------------------- 1 | 2 | namespace narly_testing { 3 | class SehAslr { 4 | public: 5 | static __declspec(dllexport) char *A(); 6 | }; 7 | } -------------------------------------------------------------------------------- /narly/dll_seh_aslr/dll_seh_aslr.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200} 23 | Win32Proj 24 | dll_seh_aslr 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | Unicode 31 | 32 | 33 | DynamicLibrary 34 | true 35 | Unicode 36 | 37 | 38 | DynamicLibrary 39 | false 40 | true 41 | MultiByte 42 | Static 43 | 44 | 45 | DynamicLibrary 46 | false 47 | true 48 | MultiByte 49 | Static 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | true 69 | 70 | 71 | true 72 | 73 | 74 | false 75 | 76 | 77 | false 78 | 79 | 80 | 81 | 82 | 83 | Level3 84 | Disabled 85 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_SEH_ASLR_EXPORTS;%(PreprocessorDefinitions) 86 | ProgramDatabase 87 | false 88 | 89 | 90 | Windows 91 | true 92 | false 93 | false 94 | 95 | 96 | 97 | 98 | 99 | 100 | Level3 101 | Disabled 102 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_SEH_ASLR_EXPORTS;%(PreprocessorDefinitions) 103 | ProgramDatabase 104 | false 105 | 106 | 107 | Windows 108 | true 109 | false 110 | false 111 | 112 | 113 | 114 | 115 | Level3 116 | 117 | 118 | MaxSpeed 119 | true 120 | true 121 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_SEH_ASLR_EXPORTS;%(PreprocessorDefinitions) 122 | false 123 | false 124 | 125 | 126 | Windows 127 | true 128 | true 129 | true 130 | false 131 | false 132 | 133 | 134 | 135 | 136 | Level3 137 | 138 | 139 | MaxSpeed 140 | true 141 | true 142 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_SEH_ASLR_EXPORTS;%(PreprocessorDefinitions) 143 | false 144 | false 145 | 146 | 147 | Windows 148 | true 149 | true 150 | true 151 | false 152 | false 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | -------------------------------------------------------------------------------- /narly/dll_seh_aslr/dll_seh_aslr.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Header Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /narly/dll_seh_aslr/dll_seh_aslr.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /narly/dll_seh_dep/dll_seh_dep.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include "dll_seh_dep.h" 3 | 4 | namespace narly_testing { 5 | char * SehDep::A() { 6 | return "seh dep"; 7 | }; 8 | } -------------------------------------------------------------------------------- /narly/dll_seh_dep/dll_seh_dep.h: -------------------------------------------------------------------------------- 1 | 2 | namespace narly_testing { 3 | class SehDep { 4 | public: 5 | static __declspec(dllexport) char *A(); 6 | }; 7 | } -------------------------------------------------------------------------------- /narly/dll_seh_dep/dll_seh_dep.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182} 23 | Win32Proj 24 | dll_seh_dep 25 | 26 | 27 | 28 | DynamicLibrary 29 | true 30 | Unicode 31 | 32 | 33 | DynamicLibrary 34 | true 35 | Unicode 36 | 37 | 38 | DynamicLibrary 39 | false 40 | true 41 | MultiByte 42 | Static 43 | 44 | 45 | DynamicLibrary 46 | false 47 | true 48 | MultiByte 49 | Static 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | true 69 | 70 | 71 | true 72 | 73 | 74 | false 75 | 76 | 77 | false 78 | 79 | 80 | 81 | 82 | 83 | Level3 84 | Disabled 85 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_SEH_DEP_EXPORTS;%(PreprocessorDefinitions) 86 | 87 | 88 | Windows 89 | true 90 | 91 | 92 | 93 | 94 | 95 | 96 | Level3 97 | Disabled 98 | WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_SEH_DEP_EXPORTS;%(PreprocessorDefinitions) 99 | 100 | 101 | Windows 102 | true 103 | 104 | 105 | 106 | 107 | Level3 108 | 109 | 110 | MaxSpeed 111 | true 112 | true 113 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_SEH_DEP_EXPORTS;%(PreprocessorDefinitions) 114 | false 115 | 116 | 117 | Windows 118 | true 119 | true 120 | true 121 | false 122 | false 123 | 124 | 125 | 126 | 127 | Level3 128 | 129 | 130 | MaxSpeed 131 | true 132 | true 133 | WIN32;NDEBUG;_WINDOWS;_USRDLL;DLL_SEH_DEP_EXPORTS;%(PreprocessorDefinitions) 134 | false 135 | 136 | 137 | Windows 138 | true 139 | true 140 | true 141 | false 142 | false 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | -------------------------------------------------------------------------------- /narly/dll_seh_dep/dll_seh_dep.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Header Files 25 | 26 | 27 | -------------------------------------------------------------------------------- /narly/dll_seh_dep/dll_seh_dep.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /narly/narly.cpp: -------------------------------------------------------------------------------- 1 | // narly.cpp 2 | // N for gnarly! 3 | 4 | #include "narly.h" 5 | #include "tokenizer.h" 6 | 7 | using namespace std; 8 | 9 | extern "C" HRESULT ExtQuery(PDEBUG_CLIENT4 Client) { 10 | g_DebugMode = false; 11 | g_DebugClient = Client; 12 | 13 | if(DebugCreate(__uuidof(IDebugSymbols3),(void **)&g_DebugSymbols) != S_OK) { 14 | ExtRelease(); 15 | return S_FALSE; 16 | } 17 | if(DebugCreate(__uuidof(IDebugDataSpaces3),(void **)&g_DebugDataSpaces) != S_OK) { 18 | ExtRelease(); 19 | return S_FALSE; 20 | } 21 | if(g_DebugClient->QueryInterface(__uuidof(IDebugControl4), (void **)&g_DebugControl) != S_OK) { 22 | ExtRelease(); 23 | return S_FALSE; 24 | } 25 | 26 | return S_OK; 27 | } 28 | 29 | void ExtRelease(void) { 30 | IUnknown **unknowns[] = {(IUnknown **) &g_DebugSymbols, 31 | (IUnknown **) &g_DebugControl, 32 | (IUnknown **) &g_DebugDataSpaces}; 33 | UINT i; 34 | UINT numUnknowns = sizeof(unknowns) / sizeof(IUnknown *); 35 | 36 | for(i = 0; i < numUnknowns; i++) { 37 | (*unknowns[i])->Release(); 38 | *unknowns[i] = NULL; 39 | } 40 | } 41 | 42 | // The entry point for the extension 43 | extern "C" HRESULT CALLBACK DebugExtensionInitialize(PULONG Version, PULONG Flags) { 44 | PDEBUG_CLIENT debugClient; 45 | PDEBUG_CONTROL debugControl; 46 | if(DebugCreate(__uuidof(IDebugClient),(void **)&debugClient) != S_OK) { 47 | return S_FALSE; 48 | } 49 | if(debugClient->QueryInterface(__uuidof(IDebugControl),(void **)&debugControl) == S_OK) { 50 | ExtensionApis.nSize = sizeof(ExtensionApis); 51 | debugControl->GetWindbgExtensionApis64((PWINDBG_EXTENSION_APIS64) &ExtensionApis); 52 | debugControl->Release(); 53 | } 54 | debugClient->Release(); 55 | 56 | dprintf("\n"); 57 | dprintf(" __s|I}*!{a. ._s,aan2*a\n"); 58 | dprintf(" _wY1+~- )S, .ae\"~=:...:X\n"); 59 | dprintf(" .vXl+:. -4c <2+=|==::..:d\n"); 60 | dprintf(" vvi=;.. -?o, =2=+==:::...=d\n"); 61 | dprintf(" )nv=:. )5, .2=--.......-=d\n"); 62 | dprintf(" ue+:: -*s ==::.. ._, )2d\n"); 67 | dprintf(" X=)vvvvIliii:3; -!s. :)s. )e.-{%%i. )c==-. :o` \"1,:+iI,)c:Sonnvli||=v(\n"); 72 | dprintf(" X>{ii+;:- .u( \"o,-{Iw(:nvvvllii=v2\n"); 73 | dprintf(" S=i||;:. .=u( -!o,+I(:iiillii|ie`\n"); 74 | dprintf(" 2>v|==__su?` -?o,-:==||iisv\"\n"); 75 | dprintf(" {nvnI!\"\"~ -!sasvv}\"\"`\n"); 76 | dprintf("\n"); 77 | dprintf(" by Nephi Johnson (d0c_s4vage)\n"); 78 | dprintf(" N for gnarly!\n"); 79 | dprintf("\n"); 80 | dprintf("Available commands:\n" 81 | "\n" 82 | " !nmod - display /SafeSEH, /GS, DEP, and ASLR info for\n" 83 | " all loaded modules\n" 84 | "\n"); 85 | 86 | return S_OK; 87 | } 88 | 89 | extern "C" HRESULT CALLBACK DebugExtensionUninitialize(void) { 90 | if(g_DebugClient) { 91 | g_DebugClient->Release(); 92 | g_DebugClient = NULL; 93 | } 94 | 95 | return S_OK; 96 | } 97 | 98 | /* 99 | * !narlymod - Lists all informatino about all loaded modules. The current 100 | * implementation lists /SafeSEH, /GS, NO_SEH, and ASLR and DEP info/compatiblities 101 | * 102 | */ 103 | HRESULT CALLBACK nmod(PDEBUG_CLIENT4 Client, PCSTR args) { 104 | INIT_API(); 105 | 106 | if(strstr(args, "/debug") || strstr(args, "/v") || strstr(args, "/verbose")) { 107 | g_DebugMode = true; 108 | } 109 | 110 | if(strstr(args, "help") || strstr(args, "/?")) { 111 | dprintf("Summary:\n" 112 | "\n" 113 | " !nmod lists all of the loaded and unloaded modules, displaying\n" 114 | " info on /SafeSEH, NO_SEH, /GS, and ASLR and DEP compatibility\n" 115 | "\n" 116 | "Usage: !nmod [/v /help]\n" 117 | "\n" 118 | " /debug - Display verbose output\n" 119 | " /verbose\n" 120 | " /v\n" 121 | "\n" 122 | " help - Who knows what this might do. I wouldn't try it if\n" 123 | " /? I were you though.\n"); 124 | ExtRelease(); 125 | return S_OK; 126 | } 127 | 128 | BOOL unloadedModulesPrinted = false; 129 | ULONG i=0, numModulesLoaded=0, numModulesUnloaded=0, currModuleNameSize=0, 130 | currImageNameSize=0, currLoadedImageNameSize=0; 131 | ULONG64 currModuleBase=0; 132 | IMAGE_NT_HEADERS64 currModuleHeaders; 133 | CHAR currModuleName[1024]; memset(currModuleName, 0, sizeof(currModuleName)); 134 | CHAR currImageName[1024]; memset(currModuleName, 0, sizeof(currImageName)); 135 | CHAR currLoadedImageName[1024]; memset(currLoadedImageName, 0, sizeof(currLoadedImageName)); 136 | 137 | g_DebugSymbols->GetNumberModules(&numModulesLoaded, &numModulesUnloaded); 138 | 139 | while(g_DebugSymbols->GetModuleByIndex(i, &currModuleBase) == S_OK) { 140 | g_DebugSymbols->GetModuleNames(i, currModuleBase, currImageName, sizeof(currImageName)-1, 141 | &currImageNameSize, currModuleName, sizeof(currModuleName)-1, 142 | &currModuleNameSize, currLoadedImageName, sizeof(currLoadedImageName)-1, 143 | &currLoadedImageNameSize); 144 | 145 | g_DebugDataSpaces->ReadImageNtHeaders(currModuleBase, &currModuleHeaders); 146 | 147 | DEBUG("\ninspecting module %d: %s\n", i, (strlen(currModuleName)==0? currImageName : currModuleName)); 148 | 149 | // unloaded module 150 | if(strlen(currModuleName) == 0) { 151 | if(!unloadedModulesPrinted) { 152 | dprintf("\nUnloaded modules:\n"); 153 | unloadedModulesPrinted = true; 154 | } 155 | dprintf("%08x %08x %-20s\n", (DWORD)currModuleBase, 156 | (DWORD)currModuleBase+currModuleHeaders.OptionalHeader.SizeOfImage, 157 | currImageName); 158 | } else { 159 | dprintf("%08x %08x %-20s %-12s %-3s %-5s %-4s %s\n", 160 | (DWORD)currModuleBase, 161 | (DWORD)currModuleBase+currModuleHeaders.OptionalHeader.SizeOfImage, 162 | currModuleName, 163 | (ModuleUtils::hasSEH(i) ? (ModuleUtils::hasSafeSEH(i) ? "/SafeSEH ON" : "/SafeSEH OFF") : "NO_SEH"), 164 | (ModuleUtils::hasGS(i) ? "/GS" : ""), 165 | (ModuleUtils::isDynBaseCompat(i) ? "*ASLR" : ""), 166 | (ModuleUtils::isNXCompat(i) ? "*DEP" : ""), 167 | currImageName); 168 | } 169 | 170 | currModuleBase = 0; 171 | memset(&currModuleHeaders, 0, sizeof(currModuleHeaders)); 172 | memset(currModuleName, 0, sizeof(currModuleName)); 173 | memset(currImageName, 0, sizeof(currImageName)); 174 | memset(currLoadedImageName, 0, sizeof(currLoadedImageName)); 175 | i++; 176 | } 177 | 178 | dprintf("\n*DEP/*ASLR means that these modules are compatible with ASLR/DEP\n"); 179 | 180 | ExtRelease(); 181 | return S_OK; 182 | } 183 | 184 | LPEXT_API_VERSION WDBGAPI ExtensionApiVersion (void) 185 | { 186 | return &g_ExtApiVersion; 187 | } -------------------------------------------------------------------------------- /narly/narly.def: -------------------------------------------------------------------------------- 1 | LIBRARY "narly" 2 | VERSION 0.1 3 | EXPORTS 4 | 5 | DebugExtensionInitialize PRIVATE 6 | DebugExtensionUninitialize PRIVATE 7 | 8 | nmod -------------------------------------------------------------------------------- /narly/narly.h: -------------------------------------------------------------------------------- 1 | // narly.h 2 | // N for gnarly! 3 | 4 | #ifndef _NARLY_H 5 | #define _NARLY_H 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | bool g_DebugMode = false; 16 | PDEBUG_SYMBOLS3 g_DebugSymbols; 17 | PDEBUG_CONTROL4 g_DebugControl; 18 | PDEBUG_DATA_SPACES3 g_DebugDataSpaces; 19 | PDEBUG_CLIENT4 g_DebugClient; 20 | WINDBG_EXTENSION_APIS ExtensionApis; 21 | 22 | extern "C" HRESULT ExtQuery(PDEBUG_CLIENT4 Client); 23 | void ExtRelease(void); 24 | ULONG64 resolveFunctionByName(char *funcName); 25 | 26 | #define DEBUG(...) if(g_DebugMode) { dprintf(__VA_ARGS__); } 27 | #define INIT_API() HRESULT Status; if ((Status = ExtQuery(Client)) != S_OK) return Status; 28 | #define EXT_RELEASE(Unk) ((Unk) != NULL ? ((Unk)->Release(), (Unk) = NULL) : NULL) 29 | 30 | EXT_API_VERSION g_ExtApiVersion = {1,1,EXT_API_VERSION_NUMBER,0} ; 31 | 32 | namespace ModuleUtils { 33 | 34 | bool hasSEH(ULONG moduleIndex) { 35 | IMAGE_NT_HEADERS64 moduleHeaders; 36 | ULONG64 moduleBase; 37 | g_DebugSymbols->GetModuleByIndex(moduleIndex, &moduleBase); 38 | g_DebugDataSpaces->ReadImageNtHeaders(moduleBase, &moduleHeaders); 39 | 40 | DEBUG("\n Checking for NO_SEH flag\n"); 41 | 42 | if(moduleHeaders.OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NO_SEH) { 43 | DEBUG(" IMAGE_OPTIONAL_HEADER.DllCharacteristics has IMAGE_DLLCHARACTERISTICS_NO_SEH\n"); 44 | DEBUG(" -does not have SEH!\n"); 45 | return false; 46 | } else { 47 | DEBUG(" IMAGE_DLLCHARACTERISTICS_NO_SEH in IMAGE_OPTIONAL_HEADER.DllCharacteristics is not present\n"); 48 | DEBUG(" -has at least SEH\n"); 49 | return true; 50 | } 51 | }; 52 | 53 | bool isDynBaseCompat(ULONG moduleIndex) { 54 | IMAGE_NT_HEADERS64 moduleHeaders; 55 | ULONG64 moduleBase; 56 | g_DebugSymbols->GetModuleByIndex(moduleIndex, &moduleBase); 57 | g_DebugDataSpaces->ReadImageNtHeaders(moduleBase, &moduleHeaders); 58 | 59 | DEBUG("\n Checking for DYNAMIC_BASE flag\n"); 60 | 61 | if(moduleHeaders.OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE) { 62 | DEBUG(" IMAGE_OPTIONAL_HEADER.DllCharacteristics has IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE\n"); 63 | DEBUG(" -is ASLR compatible!\n"); 64 | return true; 65 | } else { 66 | DEBUG(" IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE in IMAGE_OPTIONAL_HEADER.DllCharacteristics is not present\n"); 67 | DEBUG(" -is NOT ASLR compatible\n"); 68 | return false; 69 | } 70 | }; 71 | 72 | bool isNXCompat(ULONG moduleIndex) { 73 | IMAGE_NT_HEADERS64 moduleHeaders; 74 | ULONG64 moduleBase; 75 | g_DebugSymbols->GetModuleByIndex(moduleIndex, &moduleBase); 76 | g_DebugDataSpaces->ReadImageNtHeaders(moduleBase, &moduleHeaders); 77 | 78 | DEBUG("\n Checking for NX_COMPAT flag\n"); 79 | 80 | if(moduleHeaders.OptionalHeader.DllCharacteristics & IMAGE_DLLCHARACTERISTICS_NX_COMPAT) { 81 | DEBUG(" IMAGE_OPTIONAL_HEADER.DllCharacteristics has IMAGE_DLLCHARACTERISTICS_NX_COMPAT\n"); 82 | DEBUG(" -is DEP compatible!\n"); 83 | return true; 84 | } else { 85 | DEBUG(" IMAGE_DLLCHARACTERISTICS_NX_COMPAT in IMAGE_OPTIONAL_HEADER.DllCharacteristics is not present\n"); 86 | DEBUG(" -is NOT DEP compatible\n"); 87 | return false; 88 | } 89 | }; 90 | 91 | bool hasSafeSEH(ULONG moduleIndex) { 92 | IMAGE_LOAD_CONFIG_DIRECTORY moduleConfig; 93 | IMAGE_NT_HEADERS64 moduleHeaders; 94 | DWORD loadConfigSize; 95 | ULONG bytesRead=0; 96 | ULONG64 moduleBase=0, loadConfigVA=0; 97 | g_DebugSymbols->GetModuleByIndex(moduleIndex, &moduleBase); 98 | g_DebugDataSpaces->ReadImageNtHeaders(moduleBase, &moduleHeaders); 99 | loadConfigVA = moduleHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress; 100 | loadConfigSize = moduleHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].Size; 101 | 102 | DEBUG("\n Checking for /SafeSEH\n"); 103 | 104 | DEBUG(" IMAGE_OPTIONAL_HEADER.DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress: %08x\n", (DWORD)loadConfigVA); 105 | 106 | if(loadConfigVA == 0) { 107 | DEBUG(" IMAGE_OPTIONAL_HEADER.DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress was 0\n"); 108 | DEBUG(" -can't have SafeSEH without an IMAGE_LOAD_CONFIG_DIRECTORY\n"); 109 | return false; 110 | } 111 | 112 | g_DebugDataSpaces->ReadVirtual(moduleBase+loadConfigVA, (PVOID)&moduleConfig, 113 | sizeof(moduleConfig), &bytesRead); 114 | 115 | DEBUG(" IMAGE_LOAD_CONFIG_DIRECTORY.SEHandlerTable: %08x\n", (DWORD)moduleConfig.SEHandlerTable); 116 | DEBUG(" IMAGE_LOAD_CONFIG_DIRECTORY.SEHandlerCount: %08x\n", (DWORD)moduleConfig.SEHandlerCount); 117 | 118 | if(moduleConfig.SEHandlerCount == 0) { 119 | DEBUG(" IMAGE_LOAD_CONFIG_DIRECTORY.SEHandlerCount was 0\n"); 120 | DEBUG(" -no registered handles == no SafeSEH\n"); 121 | return false; 122 | } 123 | 124 | DEBUG(" module has an IMAGE_LOAD_CONFIG_DIRECTORY and the SEHandlerCount > 0\n"); 125 | DEBUG(" -has SafeSEH\n"); 126 | 127 | return true; 128 | }; 129 | 130 | bool hasGS(ULONG moduleIndex) { 131 | IMAGE_NT_HEADERS64 moduleHeaders; 132 | IMAGE_LOAD_CONFIG_DIRECTORY32 moduleConfig; 133 | DWORD loadConfigSize=0, securityCookieAddr=0, securityCookieVal=0; 134 | ULONG bytesRead=0; 135 | ULONG64 moduleBase=0, loadConfigVA=0; 136 | g_DebugSymbols->GetModuleByIndex(moduleIndex, &moduleBase); 137 | g_DebugDataSpaces->ReadImageNtHeaders(moduleBase, &moduleHeaders); 138 | loadConfigVA = moduleHeaders.OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress; 139 | 140 | DEBUG("\n Checking for /GS\n"); 141 | 142 | DEBUG(" IMAGE_OPTIONAL_HEADER.DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress: %08x\n", (DWORD)loadConfigVA); 143 | 144 | if(loadConfigVA == 0) { 145 | DEBUG(" IMAGE_OPTIONAL_HEADER.DataDirectory[IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG].VirtualAddress was 0\n"); 146 | DEBUG(" -can't have /GS without it\n"); 147 | return false; 148 | } 149 | 150 | g_DebugDataSpaces->ReadVirtual(moduleBase+loadConfigVA, (PVOID)&moduleConfig, 151 | sizeof(moduleConfig), &bytesRead); 152 | 153 | DEBUG(" IMAGE_LOAD_CONFIG_DIRECTORY.SecurityCookie (is an address): %08x\n", moduleConfig.SecurityCookie); 154 | 155 | // read the actual value of the security cookie 156 | if(moduleConfig.SecurityCookie == 0) { 157 | DEBUG(" IMAGE_LOAD_CONFIG_DIRECTORY.SecurityCookie was 0\n"); 158 | DEBUG(" -pointer to securitiy cookie == 0 (no /GS)\n"); 159 | return false; 160 | } 161 | 162 | g_DebugDataSpaces->ReadVirtual(moduleConfig.SecurityCookie, (PVOID)&securityCookieVal, 163 | sizeof(DWORD), &bytesRead); 164 | 165 | DEBUG(" Security cookie value: %08x\n", securityCookieVal); 166 | 167 | if(securityCookieVal == 0) { 168 | DEBUG(" Security cookie value was 0\n"); 169 | DEBUG(" -essentially makes /GS be turned off\n"); 170 | return false; 171 | } 172 | 173 | DEBUG(" module has an IMAGE_LOAD_CONFIG_DIRECTORY, SecurityCookie != 0, and the value != 0\n"); 174 | DEBUG(" -has /GS\n"); 175 | 176 | return true; 177 | }; 178 | } 179 | 180 | #endif // #define _NARLY_H -------------------------------------------------------------------------------- /narly/narly.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual C++ Express 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "narly", "narly.vcxproj", "{D063CAE4-2095-4144-A41F-BE6CF2A0A94C}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "narly_tester", "narly_tester\narly_tester.vcxproj", "{D8754D67-CCEA-460A-B339-EEBFA6455836}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll_seh_aslr", "dll_seh_aslr\dll_seh_aslr.vcxproj", "{0982C3FA-A36D-4022-8B86-3CCB4CF3A200}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll_seh_dep", "dll_seh_dep\dll_seh_dep.vcxproj", "{4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll_safeseh_gs", "dll_safeseh_gs\dll_safeseh_gs.vcxproj", "{E2630795-74BC-431C-B71C-1E8BA3457126}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dll_all", "dll_all\dll_all.vcxproj", "{656B519A-289D-4803-B9A5-98D0F034DC03}" 15 | EndProject 16 | Global 17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 18 | Debug|Win32 = Debug|Win32 19 | Debug|x64 = Debug|x64 20 | Release|Win32 = Release|Win32 21 | Release|x64 = Release|x64 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C}.Debug|Win32.Build.0 = Debug|Win32 26 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C}.Debug|x64.ActiveCfg = Debug|x64 27 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C}.Debug|x64.Build.0 = Debug|x64 28 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C}.Release|Win32.ActiveCfg = Release|Win32 29 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C}.Release|Win32.Build.0 = Release|Win32 30 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C}.Release|x64.ActiveCfg = Release|x64 31 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C}.Release|x64.Build.0 = Release|x64 32 | {D8754D67-CCEA-460A-B339-EEBFA6455836}.Debug|Win32.ActiveCfg = Debug|Win32 33 | {D8754D67-CCEA-460A-B339-EEBFA6455836}.Debug|Win32.Build.0 = Debug|Win32 34 | {D8754D67-CCEA-460A-B339-EEBFA6455836}.Debug|x64.ActiveCfg = Debug|x64 35 | {D8754D67-CCEA-460A-B339-EEBFA6455836}.Debug|x64.Build.0 = Debug|x64 36 | {D8754D67-CCEA-460A-B339-EEBFA6455836}.Release|Win32.ActiveCfg = Release|Win32 37 | {D8754D67-CCEA-460A-B339-EEBFA6455836}.Release|Win32.Build.0 = Release|Win32 38 | {D8754D67-CCEA-460A-B339-EEBFA6455836}.Release|x64.ActiveCfg = Release|x64 39 | {D8754D67-CCEA-460A-B339-EEBFA6455836}.Release|x64.Build.0 = Release|x64 40 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200}.Debug|Win32.ActiveCfg = Debug|Win32 41 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200}.Debug|Win32.Build.0 = Debug|Win32 42 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200}.Debug|x64.ActiveCfg = Debug|x64 43 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200}.Debug|x64.Build.0 = Debug|x64 44 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200}.Release|Win32.ActiveCfg = Release|Win32 45 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200}.Release|Win32.Build.0 = Release|Win32 46 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200}.Release|x64.ActiveCfg = Release|x64 47 | {0982C3FA-A36D-4022-8B86-3CCB4CF3A200}.Release|x64.Build.0 = Release|x64 48 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}.Debug|Win32.ActiveCfg = Debug|Win32 49 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}.Debug|Win32.Build.0 = Debug|Win32 50 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}.Debug|x64.ActiveCfg = Debug|x64 51 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}.Debug|x64.Build.0 = Debug|x64 52 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}.Release|Win32.ActiveCfg = Release|Win32 53 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}.Release|Win32.Build.0 = Release|Win32 54 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}.Release|x64.ActiveCfg = Release|x64 55 | {4DADBD2B-C90B-4AF5-8B4C-B027EFC67182}.Release|x64.Build.0 = Release|x64 56 | {E2630795-74BC-431C-B71C-1E8BA3457126}.Debug|Win32.ActiveCfg = Debug|Win32 57 | {E2630795-74BC-431C-B71C-1E8BA3457126}.Debug|Win32.Build.0 = Debug|Win32 58 | {E2630795-74BC-431C-B71C-1E8BA3457126}.Debug|x64.ActiveCfg = Debug|x64 59 | {E2630795-74BC-431C-B71C-1E8BA3457126}.Debug|x64.Build.0 = Debug|x64 60 | {E2630795-74BC-431C-B71C-1E8BA3457126}.Release|Win32.ActiveCfg = Release|Win32 61 | {E2630795-74BC-431C-B71C-1E8BA3457126}.Release|Win32.Build.0 = Release|Win32 62 | {E2630795-74BC-431C-B71C-1E8BA3457126}.Release|x64.ActiveCfg = Release|x64 63 | {E2630795-74BC-431C-B71C-1E8BA3457126}.Release|x64.Build.0 = Release|x64 64 | {656B519A-289D-4803-B9A5-98D0F034DC03}.Debug|Win32.ActiveCfg = Debug|Win32 65 | {656B519A-289D-4803-B9A5-98D0F034DC03}.Debug|Win32.Build.0 = Debug|Win32 66 | {656B519A-289D-4803-B9A5-98D0F034DC03}.Debug|x64.ActiveCfg = Debug|x64 67 | {656B519A-289D-4803-B9A5-98D0F034DC03}.Debug|x64.Build.0 = Debug|x64 68 | {656B519A-289D-4803-B9A5-98D0F034DC03}.Release|Win32.ActiveCfg = Release|Win32 69 | {656B519A-289D-4803-B9A5-98D0F034DC03}.Release|Win32.Build.0 = Release|Win32 70 | {656B519A-289D-4803-B9A5-98D0F034DC03}.Release|x64.ActiveCfg = Release|x64 71 | {656B519A-289D-4803-B9A5-98D0F034DC03}.Release|x64.Build.0 = Release|x64 72 | EndGlobalSection 73 | GlobalSection(SolutionProperties) = preSolution 74 | HideSolutionNode = FALSE 75 | EndGlobalSection 76 | EndGlobal 77 | -------------------------------------------------------------------------------- /narly/narly.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 26 | 29 | 32 | 35 | 38 | 41 | 53 | 56 | 59 | 62 | 72 | 75 | 78 | 81 | 84 | 87 | 90 | 93 | 94 | 102 | 105 | 108 | 111 | 114 | 117 | 129 | 132 | 135 | 138 | 150 | 153 | 156 | 159 | 162 | 165 | 168 | 171 | 172 | 173 | 174 | 175 | 176 | 181 | 184 | 185 | 188 | 189 | 192 | 195 | 199 | 200 | 203 | 207 | 208 | 209 | 210 | 215 | 218 | 219 | 222 | 223 | 226 | 227 | 230 | 231 | 232 | 237 | 238 | 241 | 242 | 243 | 244 | 245 | 246 | -------------------------------------------------------------------------------- /narly/narly.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {D063CAE4-2095-4144-A41F-BE6CF2A0A94C} 23 | narly 24 | Win32Proj 25 | 26 | 27 | 28 | DynamicLibrary 29 | MultiByte 30 | true 31 | 32 | 33 | DynamicLibrary 34 | MultiByte 35 | true 36 | 37 | 38 | DynamicLibrary 39 | MultiByte 40 | 41 | 42 | DynamicLibrary 43 | MultiByte 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | <_ProjectFileVersion>10.0.30319.1 63 | $(SolutionDir)$(Configuration)\ 64 | $(SolutionDir)$(Configuration)\ 65 | $(Configuration)\ 66 | $(Configuration)\ 67 | true 68 | true 69 | $(SolutionDir)$(Configuration)\ 70 | $(SolutionDir)$(Configuration)x64\ 71 | $(Configuration)\ 72 | $(Configuration)x64\ 73 | false 74 | false 75 | 76 | 77 | 78 | Disabled 79 | C:\Program Files\Debugging Tools for Windows (x64)\sdk\inc;%(AdditionalIncludeDirectories) 80 | WIN32;_DEBUG;_WINDOWS;_USRDLL;NARLY_EXPORTS;%(PreprocessorDefinitions) 81 | true 82 | EnableFastChecks 83 | MultiThreaded 84 | 85 | 86 | Level3 87 | EditAndContinue 88 | 89 | 90 | dbgeng.lib;engextcpp.lib;%(AdditionalDependencies) 91 | C:\Program Files\Debugging Tools for Windows (x64)\sdk\lib\i386;%(AdditionalLibraryDirectories) 92 | narly.def 93 | true 94 | Windows 95 | MachineX86 96 | 97 | 98 | 99 | 100 | Disabled 101 | C:\Program Files\Debugging Tools for Windows (x64)\sdk\inc;%(AdditionalIncludeDirectories) 102 | WIN32;_DEBUG;_WINDOWS;_USRDLL;NARLY_EXPORTS;%(PreprocessorDefinitions) 103 | EnableFastChecks 104 | MultiThreaded 105 | 106 | 107 | Level3 108 | ProgramDatabase 109 | 110 | 111 | dbgeng.lib;engextcpp.lib;%(AdditionalDependencies) 112 | C:\Program Files\Debugging Tools for Windows (x64)\sdk\lib\i386;%(AdditionalLibraryDirectories) 113 | narly.def 114 | true 115 | Windows 116 | 117 | 118 | 119 | 120 | MaxSpeed 121 | true 122 | C:\Program Files\Debugging Tools for Windows (x64)\sdk\inc;%(AdditionalIncludeDirectories) 123 | WIN32;NDEBUG;_WINDOWS;_USRDLL;NARLY_EXPORTS;%(PreprocessorDefinitions) 124 | MultiThreaded 125 | true 126 | 127 | 128 | Level3 129 | ProgramDatabase 130 | 131 | 132 | dbgeng.lib;engextcpp.lib;%(AdditionalDependencies) 133 | C:\Program Files\Debugging Tools for Windows (x64)\sdk\lib\i386;%(AdditionalLibraryDirectories) 134 | narly.def 135 | true 136 | Windows 137 | true 138 | true 139 | MachineX86 140 | 141 | 142 | 143 | 144 | MaxSpeed 145 | true 146 | C:\Program Files\Debugging Tools for Windows (x64)\sdk\inc;%(AdditionalIncludeDirectories) 147 | WIN32;NDEBUG;_WINDOWS;_USRDLL;NARLY_EXPORTS;%(PreprocessorDefinitions) 148 | MultiThreaded 149 | true 150 | NotUsing 151 | Level3 152 | ProgramDatabase 153 | 154 | 155 | dbgeng.lib;engextcpp.lib;%(AdditionalDependencies) 156 | C:\Program Files\Debugging Tools for Windows (x64)\sdk\lib\amd64;C:\Program Files\Microsoft SDKs\Windows\v7.1\Lib\x64;%(AdditionalLibraryDirectories) 157 | narly.def 158 | true 159 | Windows 160 | true 161 | true 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | -------------------------------------------------------------------------------- /narly/narly.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | 23 | 24 | Source Files 25 | 26 | 27 | 28 | 29 | 30 | Header Files 31 | 32 | 33 | Header Files 34 | 35 | 36 | Header Files 37 | 38 | 39 | -------------------------------------------------------------------------------- /narly/narly.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /narly/narly_tester/narly_tester.cpp: -------------------------------------------------------------------------------- 1 | // narly_tester.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include 5 | #include "dll_all.h" 6 | #include "dll_seh_aslr.h" 7 | #include "dll_seh_dep.h" 8 | #include "dll_safeseh_gs.h" 9 | 10 | int main() 11 | { 12 | printf("called function in dll with: %s turned on\n", narly_testing::SehAslr::A()); 13 | printf("called function in dll with: %s turned on\n", narly_testing::SehDep::A()); 14 | printf("called function in dll with: %s turned on\n", narly_testing::SafeSehGs::A()); 15 | printf("called function in dll with: %s turned on\n", narly_testing::All::A()); 16 | 17 | __asm{ 18 | int 3 19 | } 20 | 21 | return 0; 22 | } -------------------------------------------------------------------------------- /narly/narly_tester/narly_tester.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | {D8754D67-CCEA-460A-B339-EEBFA6455836} 23 | Win32Proj 24 | narly_tester 25 | 26 | 27 | 28 | Application 29 | true 30 | Unicode 31 | 32 | 33 | Application 34 | true 35 | Unicode 36 | 37 | 38 | Application 39 | false 40 | true 41 | MultiByte 42 | Static 43 | 44 | 45 | Application 46 | false 47 | true 48 | MultiByte 49 | Static 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | true 69 | 70 | 71 | true 72 | 73 | 74 | false 75 | 76 | 77 | false 78 | $(SolutionDir)$(Platform)\$(Configuration)x64\ 79 | 80 | 81 | 82 | 83 | 84 | Level3 85 | Disabled 86 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 87 | $(ProjectDir)..\seh_aslr;$(ProjectDir)..\seh_dep 88 | MultiThreaded 89 | false 90 | 91 | 92 | Console 93 | true 94 | 95 | 96 | 97 | 98 | 99 | 100 | Level3 101 | Disabled 102 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 103 | $(ProjectDir)..\seh_aslr;$(ProjectDir)..\seh_dep 104 | MultiThreaded 105 | false 106 | 107 | 108 | Console 109 | true 110 | 111 | 112 | 113 | 114 | Level3 115 | 116 | 117 | Disabled 118 | true 119 | true 120 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 121 | $(ProjectDir)..\dll_all;$(ProjectDir)..\dll_safeseh_gs;$(ProjectDir)..\dll_safeseh_gs_aslr_dep;$(ProjectDir)..\dll_safeseh;$(ProjectDir)..\dll_seh_aslr;$(ProjectDir)..\dll_seh_dep;$(ProjectDir)..\dll_seh_gs 122 | MultiThreaded 123 | false 124 | false 125 | 126 | 127 | Console 128 | true 129 | true 130 | true 131 | 132 | 133 | 134 | 135 | Level3 136 | 137 | 138 | Disabled 139 | true 140 | true 141 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 142 | $(ProjectDir)..\dll_all;$(ProjectDir)..\dll_safeseh_gs;$(ProjectDir)..\dll_safeseh_gs_aslr_dep;$(ProjectDir)..\dll_safeseh;$(ProjectDir)..\dll_seh_aslr;$(ProjectDir)..\dll_seh_dep;$(ProjectDir)..\dll_seh_gs 143 | MultiThreaded 144 | false 145 | false 146 | 147 | 148 | Console 149 | true 150 | true 151 | true 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | {656b519a-289d-4803-b9a5-98d0f034dc03} 168 | 169 | 170 | {e2630795-74bc-431c-b71c-1e8ba3457126} 171 | 172 | 173 | {0982c3fa-a36d-4022-8b86-3ccb4cf3a200} 174 | 175 | 176 | {4dadbd2b-c90b-4af5-8b4c-b027efc67182} 177 | 178 | 179 | 180 | 181 | 182 | -------------------------------------------------------------------------------- /narly/narly_tester/narly_tester.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | Header Files 23 | 24 | 25 | Header Files 26 | 27 | 28 | 29 | 30 | Source Files 31 | 32 | 33 | Source Files 34 | 35 | 36 | -------------------------------------------------------------------------------- /narly/narly_tester/narly_tester.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | -------------------------------------------------------------------------------- /narly/narly_tester/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // narly_tester.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /narly/narly_tester/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /narly/narly_tester/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // Including SDKDDKVer.h defines the highest available Windows platform. 4 | 5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and 6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h. 7 | 8 | #include 9 | -------------------------------------------------------------------------------- /narly/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // narly.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /narly/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | // N for gnarly! 6 | 7 | #pragma once 8 | 9 | #include "targetver.h" 10 | 11 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 12 | -------------------------------------------------------------------------------- /narly/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef WINVER // Specifies that the minimum required platform is Windows Vista. 11 | #define WINVER 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 15 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 16 | #endif 17 | 18 | #ifndef _WIN32_WINDOWS // Specifies that the minimum required platform is Windows 98. 19 | #define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later. 20 | #endif 21 | 22 | #ifndef _WIN32_IE // Specifies that the minimum required platform is Internet Explorer 7.0. 23 | #define _WIN32_IE 0x0700 // Change this to the appropriate value to target other versions of IE. 24 | #endif 25 | -------------------------------------------------------------------------------- /narly/tokenizer.h: -------------------------------------------------------------------------------- 1 | // tokenizer.h 2 | // N for gnarly! 3 | 4 | #ifndef _TOKENIZER_H 5 | #define _TOKENIZER_H 6 | 7 | using namespace std; 8 | 9 | class Tokenizer { 10 | public: 11 | Tokenizer(PCSTR inputText){ 12 | _storageBuffLength = strlen(inputText)+1; 13 | _storageBuff = (PSTR) malloc(sizeof(CHAR) * _storageBuffLength); 14 | _inputStream << inputText; 15 | }; 16 | ~Tokenizer() { 17 | free(_storageBuff); 18 | _storageBuff = NULL; 19 | }; 20 | // fetches the next token from _inputStream and stores it into storageBuff, using 21 | // delim as the delimiter 22 | PSTR next(char delim) { 23 | memset((CHAR *)_storageBuff, 0, _storageBuffLength); 24 | if(!_inputStream.getline((CHAR *)_storageBuff, _storageBuffLength-1, delim)) { 25 | return NULL; 26 | } 27 | return _storageBuff; 28 | }; 29 | 30 | private: 31 | stringstream _inputStream; 32 | PSTR _storageBuff; 33 | UINT _storageBuffLength; 34 | }; 35 | 36 | #endif // _TOKENIZER_H --------------------------------------------------------------------------------