I had some code, but not with me right now.
Using the exported api 'alarm' is what i would like to use in my program, but LoadLibraryA will not load it.
Any solutions to this?
it is located in WINNT\system32 on my win2k box, assuming it be in WINDOWS\system32 for XP
Doesn't seem to be on win9x systems.
some code was like this.
.586
.model flat,stdcall
include <windows.inc>
include <kernel32.inc>
.data
psxdll db 'psxdll.dll',0
szAlarm db 'alarm',0
.code
start:
invoke LoadLibrary,addr psxdll
invoke GetProcAddress,eax,addr szAlarm
end start
not very good, but LoadLibrary fails anyway..this is what i don't understand.
include windows.inc
include kernel32.inc
includelib kernel32.lib
and make sure that 'psxdll.dll' are in system directory or in your program path
LoadLibrary fails on my Windows 2000 SP4 system as well, with all of the includes in place, and even with a local copy of the dll. Here is the output from dumppe:
psxdll.dll (hex) (dec)
.EXE size (bytes) 490 1168
Minimum load size (bytes) 450 1104
Overlay number 0 0
Initial CS:IP 0000:0000
Initial SS:SP 0000:00B8 184
Minimum allocation (para) 0 0
Maximum allocation (para) FFFF 65535
Header size (para) 4 4
Relocation table offset 40 64
Relocation entries 0 0
Portable Executable starts at d0
Signature 00004550 (PE)
Machine 014C (Intel 386)
Sections 0006
Time Date Stamp 38439A0B Tue Nov 30 03:34:03 1999
Symbol Table 00000000
Number of Symbols 00000000
Optional header size 00E0
Characteristics 230E
Executable Image
Line numbers stripped
Local symbols stripped
32 bit word machine
Debugging information stripped
DLL
Magic 010B
Linker Version 5.12
Size of Code 00006200
Size of Initialized Data 00001400
Size of Uninitialized Data 00007C00
Address of Entry Point 0000291E
Base of Code 00001000
Base of Data 00008000
Image Base 68FE0000
Section Alignment 00001000
File Alignment 00000200
Operating System Version 5.00
Image Version 5.00
Subsystem Version 19.90
reserved 00000000
Image Size 00014000
Header Size 00000600
Checksum 00009008
Subsystem 0007 (Posix)
DLL Characteristics 0000
Size Of Stack Reserve 00040000
Size Of Stack Commit 00001000
Size Of Heap Reserve 00100000
Size Of Heap Commit 00001000
Loader Flags 00000000
Number of Directories 00000010
Directory Name VirtAddr VirtSize
-------------------------------------- -------- --------
Export 00006670 00000A6F
Import 00011000 00000028
Resource 00012000 000003B8
Exception 00000000 00000000
Security 00000000 00000000
Base Relocation 00013000 00000688
Debug 00001000 0000001C
Decription/Architecture 00000000 00000000
Machine Value (MIPS GP) 00000000 00000000
Thread Storage 00000000 00000000
Load Configuration 00000000 00000000
Bound Import 000002B8 0000001C
Import Address Table 000110D0 000000A8
Delay Import 00000000 00000000
COM Runtime Descriptor 00000000 00000000
(reserved) 00000000 00000000
Section Table
-------------
01 .text Virtual Address 00001000
Virtual Size 000060DF
Raw Data Offset 00000600
Raw Data Size 00006200
Relocation Offset 00000000
Relocation Count 0000
Line Number Offset 00000000
Line Number Count 0000
Characteristics 60000020
Code
Executable
Readable
02 .bss Virtual Address 00008000
Virtual Size 00007A1C
Raw Data Offset 00000000
Raw Data Size 00000000
Relocation Offset 00000000
Relocation Count 0000
Line Number Offset 00000000
Line Number Count 0000
Characteristics C0000080
Uninitialized Data
Readable
Writeable
03 .data Virtual Address 00010000
Virtual Size 00000008
Raw Data Offset 00006800
Raw Data Size 00000200
Relocation Offset 00000000
Relocation Count 0000
Line Number Offset 00000000
Line Number Count 0000
Characteristics C0000040
Initialized Data
Readable
Writeable
04 .idata Virtual Address 00011000
Virtual Size 00000464
Raw Data Offset 00006A00
Raw Data Size 00000600
Relocation Offset 00000000
Relocation Count 0000
Line Number Offset 00000000
Line Number Count 0000
Characteristics 40000040
Initialized Data
Readable
05 .rsrc Virtual Address 00012000
Virtual Size 000003B8
Raw Data Offset 00007000
Raw Data Size 00000400
Relocation Offset 00000000
Relocation Count 0000
Line Number Offset 00000000
Line Number Count 0000
Characteristics 40000040
Initialized Data
Readable
06 .reloc Virtual Address 00013000
Virtual Size 000007EE
Raw Data Offset 00007400
Raw Data Size 00000800
Relocation Offset 00000000
Relocation Count 0000
Line Number Offset 00000000
Line Number Count 0000
Characteristics 42000040
Initialized Data
Discardable
Readable
Exp Addr Hint Ord Export Name by PSXDLL.dll - Thu Oct 7 18:26:17 1999
-------- ---- ----- ---------------------------------------------------------
000018F4 0 1 GetProcessHeap
00006B62 1 2 HeapAlloc (forwarder -> NTDLL.RtlAllocateHeap)
00006B81 2 3 HeapFree (forwarder -> NTDLL.RtlFreeHeap)
00006B9F 3 4 HeapReAlloc (forwarder -> NTDLL.RtlReAllocateHeap)
00006BC0 4 5 HeapSize (forwarder -> NTDLL.RtlSizeHeap)
00006BEB 5 6 RtlAnsiCharToUnicodeChar (forwarder -> NTDLL.RtlAnsiCharToUnicodeChar)
00006C18 6 7 RtlFillMemory (forwarder -> NTDLL.RtlFillMemory)
00006C3A 7 8 RtlMoveMemory (forwarder -> NTDLL.RtlMoveMemory)
00006C65 8 9 RtlMultiByteToUnicodeN (forwarder -> NTDLL.RtlMultiByteToUnicodeN)
00006C99 9 10 RtlUnicodeToMultiByteN (forwarder -> NTDLL.RtlUnicodeToMultiByteN)
00006CD0 A 11 RtlUnicodeToMultiByteSize (forwarder -> NTDLL.RtlUnicodeToMultiByteSize)
00006CFA B 12 RtlUnwind (forwarder -> NTDLL.RtlUnwind)
00006D1F C 13 RtlUpcaseUnicodeChar (forwarder -> NTDLL.RtlUpcaseUnicodeChar)
00006D57 D 14 RtlUpcaseUnicodeToMultiByteN (forwarder -> NTDLL.RtlUpcaseUnicodeToMultiByteN)
00006D88 E 15 RtlZeroMemory (forwarder -> NTDLL.RtlZeroMemory)
000016FA F 16 __PdxGetCmdLine
00002C61 10 17 __PdxInitializeData
000038FF 11 18 _exit
00005D12 12 19 _sigjmp_store_mask
0000215D 13 20 access
000058AB 14 21 alarm
00005D83 15 22 cfgetispeed
00005D8B 16 23 cfgetospeed
00005D67 17 24 cfsetispeed
00005D75 18 25 cfsetospeed
00001AE4 19 26 chdir
000021F5 1A 27 chmod
00002276 1B 28 chown
00002C76 1C 29 close
00001901 1D 30 closedir
00002CC1 1E 31 creat
00005CAD 1F 32 ctermid
0000636C 20 33 cuserid
00003104 21 34 dup
00003115 22 35 dup2
00004394 23 36 execl
000043AE 24 37 execle
000043D9 25 38 execlp
0000437C 26 39 execv
000040A6 27 40 execve
00004610 28 41 execvp
00003166 29 42 fcntl
00005D83 2A 43 fileno
00003CD6 2B 44 fork
0000240E 2C 45 fpathconf
00002073 2D 46 fstat
0000346A 2E 47 ftruncate
00001C6F 2F 48 getcwd
0000393D 30 49 getegid
00004BF6 31 50 getenv
0000399F 32 51 geteuid
0000396E 33 52 getgid
000060BA 34 53 getgrgid
00006199 35 54 getgrnam
00004E4E 36 55 getgroups
000062BA 37 56 getlogin
00003A63 38 57 getpgrp
00003A32 39 58 getpid
00003A01 3A 59 getppid
00005FB1 3B 60 getpwnam
00005EFB 3C 61 getpwuid
00005A67 3D 62 getreg
000039D0 3E 63 getuid
0000332E 3F 64 isatty
000033CC 40 65 isatty2
00005435 41 66 kill
0000284E 42 67 link
00002CD7 43 68 lseek
00001DD3 44 69 mkdir
00001E5C 45 70 mkfifo
00002D2E 46 71 open
00001979 47 72 opendir
0000238D 48 73 pathconf
00005396 49 74 pause
00002DF5 4A 75 pipe
000018E2 4B 76 raise
00002E9C 4C 77 read
000019F1 4D 78 readdir
00005EBF 4E 79 remove
0000245F 4F 80 rename
00001AD7 50 81 rewinddir
00001EDC 51 82 rmdir
00005CCE 52 83 setgid
00003AD9 53 84 setpgid
00003A94 54 85 setsid
00005CEB 55 86 setuid
000050DC 56 87 sigaction
00004F4E 57 88 sigaddset
00004FCE 58 89 sigdelset
00004E9F 59 90 sigemptyset
00004EED 5A 91 sigfillset
00005050 5B 92 sigismember
00005D3E 5C 93 siglongjmp
00005492 5D 94 signal
000054C9 5E 95 sigpending
000051D7 5F 96 sigprocmask
000052C1 60 97 sigsuspend
00005911 61 98 sleep
00001F56 62 99 stat
00004E03 63 100 sysconf
00005D93 64 101 system
000056D1 65 102 tcdrain
0000576D 66 103 tcflow
0000571C 67 104 tcflush
00005566 68 105 tcgetattr
000057BE 69 106 tcgetpgrp
00005680 6A 107 tcsendbreak
000055EE 6B 108 tcsetattr
00005809 6C 109 tcsetpgrp
00004CAF 6D 110 time
00004D33 6E 111 times
00005D08 6F 112 ttyname
00001D88 70 113 umask
00004831 71 114 uname
000027D4 72 115 unlink
000022FD 73 116 utime
00003C02 74 117 wait
00003B2A 75 118 waitpid
00002FE2 76 119 write
Imp Addr Hint Import Name from ntdll.dll - Bound
-------- ---- ---------------------------------------------------------------
000110D0 17D RtlCreateHeap
000110D4 A4 NtOpenSection
000110D8 1DB RtlFreeUnicodeString
000110DC 4F NtConnectPort
000110E0 14D RtlAnsiStringToUnicodeString
000110E4 1FA RtlInitAnsiString
000110E8 20C RtlIntegerToChar
000110EC 472 sprintf
000110F0 E9 NtRequestWaitReplyPort
000110F4 4C NtClose
000110F8 9C NtOpenFile
000110FC 495 wcsrchr
00011100 490 wcslen
00011104 484 swprintf
00011108 1D7 RtlFreeHeap
0001110C 14A RtlAllocateHeap
00011110 46D memmove
00011114 1D5 RtlFreeAnsiString
00011118 285 RtlUnicodeStringToAnsiString
0001111C 47F strrchr
00011120 492 wcsncmp
00011124 94 NtMapViewOfSection
00011128 DD NtRegisterThreadTerminatePort
0001112C 1FE RtlInitUnicodeString
00011130 60 NtCreateSection
00011134 11B NtTerminateProcess
00011138 50 NtContinue
0001113C 47B strncat
00011140 2B2 RtlxAnsiStringToUnicodeSize
00011144 32 NlsMbCodePageTag
00011148 476 strchr
0001114C 177 RtlCopyString
00011150 47D strncpy
00011154 D3 NtQueryValueKey
00011158 9F NtOpenKey
0001115C CF NtQuerySystemInformation
00011160 27E RtlTimeToSecondsSince1970
00011164 D0 NtQuerySystemTime
00011168 1C3 RtlExtendedLargeIntegerDivide
0001116C 425 _allmul
00011170 290 RtlUnwind
Debug Entry
Chars TimeDate Maj Min Type Size AddrRaw PtrRaw
-------- -------- ---- ---- ---------------------- -------- -------- --------
00000000 37FD2C28 0000 0000 00000004 MISC 00000110 00000000 00007C00
MISC Debug Info
dll\psxdll.dbg
IAT Entry
00000000: 77FC925F 77F8F46D - 77F8B537 77F8C857 - 77F94511 77F9194E
00000018: 77F82883 77F874BB - 77F8AAAA 77F88578 - 77F8B5B4 77F94D3B
00000030: 77F8D1F7 77F90378 - 77FC9C41 77FC976B - 77F82A70 77F8B537
00000048: 77F8E5EC 77F825A5 - 77F89BF2 77F8682E - 77F908D6 77F87124
00000060: 77F89C33 77F8C3D8 - 77F92796 77FB7B0F - 77FA7632 77FCD314
00000078: 77F82EEF 77F85F2E - 77F8A557 77F83D9C - 77F89A99 77F95BBD
00000090: 77F91511 77F8E546 - 77F8EF95 77F93694 - 77F86118 00000000
Note the "Subsystem 0007 (Posix).
this dll (posix) requires NT/SYSTEM priveleges (dont can access as user level) as far I have read googling
So, i need to inherit SYSTEM privileges first?
How would this be done?..i assume i would have to create a security descriptor, i'll try google.
I usually place all the includelib directives at the top of the include file for less typing.
I found out last night that IT IS NOT REQUIRED to have SYSTEM privileges in order to load psxdll.dll with LoadLibrary
However, you must link the code you wish to run with SUBSYSTEM:POSIX
I have no clue still how to access the api in psxdll.dll but POSIX modules are run in a subsystem like CONSOLE/GUI/DRIVER(NATIVE)
and other SUBSYSTEM types.
Take for example DOS programs which run in NTVDM subsystem.