File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3232
3333typedef BYTE UBYTE ;
3434
35+ #ifndef UNW_FLAG_CHAININFO
36+ #define UNW_FLAG_CHAININFO 4
37+ #endif
38+
3539typedef enum _UNWIND_OP_CODES {
3640 UWOP_PUSH_NONVOL = 0 , /* info == register number */
3741 UWOP_ALLOC_LARGE , /* no info, alloc size in next 2 slots */
@@ -92,7 +96,7 @@ LPVOID GetGPA(VOID) {
9296 PBYTE s1 , e1 , s2 , e2 ;
9397 PUNWIND_INFO ui ;
9498
95- peb = ( PPEB ) __readgsqword ( 0x60 ) ;
99+ peb = NtCurrentTeb () -> ProcessEnvironmentBlock ;
96100 ldr = (PPEB_LDR_DATA )peb -> Ldr ;
97101
98102 for (dte = (PLDR_DATA_TABLE_ENTRY )ldr -> InLoadOrderModuleList .Flink ;
Original file line number Diff line number Diff line change 2727 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2828 POSSIBILITY OF SUCH DAMAGE. */
2929
30- #include "getapi .h"
30+ #include "peb .h"
3131
3232LPVOID GetGPA (VOID ) {
3333 PPEB peb ;
@@ -41,7 +41,7 @@ LPVOID GetGPA(VOID) {
4141 DWORD i , j , h ;
4242 PBYTE cs ;
4343
44- peb = ( PPEB ) __readfsdword ( 0x30 ) ;
44+ peb = NtCurrentTeb () -> ProcessEnvironmentBlock ;
4545 ldr = (PPEB_LDR_DATA )peb -> Ldr ;
4646
4747 // for each DLL loaded
@@ -86,15 +86,16 @@ LPVOID GetGPA(VOID) {
8686}
8787
8888int main (void ) {
89-
89+ LPVOID addr = GetGPA ();
90+
9091 if (addr != NULL ) {
9192 printf ("GetProcAddress: %p\n" , addr );
9293
9394 printf ("GetProcAddress: %p\n" ,
94- GetProcAddress ("kernelbase" , "GetProcAddress" ));
95+ ( LPVOID ) GetProcAddress (GetModuleHandle ( "kernelbase" ) , "GetProcAddress" ));
9596
9697 printf ("GetProcAddressForCaller: %p\n" ,
97- GetProcAddress ("kernelbase" , "GetProcAddressForCaller" ));
98+ ( LPVOID ) GetProcAddress (GetModuleHandle ( "kernelbase" ) , "GetProcAddressForCaller" ));
9899 }
99100 return 0 ;
100101}
Original file line number Diff line number Diff line change 2929
3030#include "peb.h"
3131
32+ LPVOID get_api (DWORD );
33+ LPVOID get_apix (DWORD );
34+
3235// converts string to lowercase
3336uint32_t crc32c (const char * s ) {
3437 int i ;
@@ -192,7 +195,7 @@ int main(int argc, char *argv[])
192195
193196 h = dll_h + api_h ;
194197
195- p = get_api (h );
198+ p = get_apix (h );
196199 // if not found
197200 if (p == NULL ) {
198201 // load the module into memory
@@ -201,7 +204,7 @@ int main(int argc, char *argv[])
201204 return 0 ;
202205 }
203206 // then try again
204- p = get_api (h );
207+ p = get_apix (h );
205208 }
206209 if (p == NULL ) {
207210 printf ("\nUnable to locate API address \"%s\"" , argv [2 ]);
Original file line number Diff line number Diff line change 3333#define PEB_H
3434
3535#include <windows.h>
36+ #include <stdio.h>
37+ #include <stdint.h>
3638
3739#ifndef ROTR32
3840#define ROTR32 (v ,n )(((v)>>(n))|((v)<<(32-(n))))
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments