Skip to content

Commit

Permalink
[DLL] Drop .dll
Browse files Browse the repository at this point in the history
  • Loading branch information
PeyTy committed Jun 23, 2024
1 parent 59feae5 commit 47bad4f
Show file tree
Hide file tree
Showing 46 changed files with 76 additions and 39 deletions.
8 changes: 4 additions & 4 deletions build/main.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ fun runTasks() {
// DLL
phase1.push(
nasm + ' -f win64 -o ' +
folder + '\\tofita64.asm.obj dlls\\tofita32.dll\\tofita64.asm'
folder + '\\tofita64.asm.obj dlls\\tofita64.asm'
)

phase1.push(
nasm + ' -f win32 -o ' +
folder + '\\tofita32.asm.obj dlls\\tofita32.dll\\tofita32.asm'
folder + '\\tofita32.asm.obj dlls\\tofita32.asm'
)
}

Expand Down Expand Up @@ -331,9 +331,9 @@ fun runTasks() {
// TODO libgen txt list here, to .lib in phase 2
// TODO --define bit32
if bit == '32' {
phase1.push('cmd /c hexa --output-folder ' + folder + ' --define bit64=false dlls\\\(dlls[i]).dll\\hexa.json --target i386')
phase1.push('cmd /c hexa --output-folder ' + folder + ' --define bit64=false dlls\\\(dlls[i])\\hexa.json --target i386')
} else {
phase1.push('cmd /c hexa --output-folder ' + folder + ' --define bit64=true dlls\\\(dlls[i]).dll\\hexa.json --target default')
phase1.push('cmd /c hexa --output-folder ' + folder + ' --define bit64=true dlls\\\(dlls[i])\\hexa.json --target default')
}

// TODO refactor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,35 @@
@dllExport('RegCloseKey')
fun regCloseKey(stub SizeOfPointer) SizeOfPointer {
// TODO
tofitaDebugLog("regCloseKey()\n".utf16())
return 0
}

@dllExport('RegCreateKeyExW')
fun regCreateKeyExW(stub SizeOfPointer) SizeOfPointer {
// TODO
tofitaDebugLog("regCreateKeyExW()\n".utf16())
return 0
}

@dllExport('RegOpenKeyExW')
fun regOpenKeyExW(stub SizeOfPointer) SizeOfPointer {
// TODO
tofitaDebugLog("regOpenKeyExW()\n".utf16())
return 0
}

@dllExport('RegQueryValueExW')
fun regQueryValueExW(stub SizeOfPointer) SizeOfPointer {
// TODO
tofitaDebugLog("regQueryValueExW()\n".utf16())
return 0
}

@dllExport('RegSetValueExW')
fun regSetValueExW(stub SizeOfPointer) SizeOfPointer {
// TODO
tofitaDebugLog("regSetValueExW()\n".utf16())
return 0
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
}

#ifdef bit64
// TODO why separate fun? same arguments?
__attribute__((fastcall)) void _DllMainCRTStartup() {
startup();
}
Expand Down
6 changes: 3 additions & 3 deletions dlls/advapi32.dll/hexa.json → dlls/advapi32/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"global": [
"../types",
"../../engine/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"../tofita32/tofita32.header",
"../kernel32/kernel32.header",
"../ntdll/ntdll.header",
"advapiMain"
],
"targets": [
Expand Down
File renamed without changes.
19 changes: 10 additions & 9 deletions dlls/comctl32.dll/comctl32.hexa → dlls/comctl32/comctl32.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

@dllExport('InitCommonControls')
fun initCommonControls(stub SizeOfPointer) SizeOfPointer {
// TODO
return 0
fun initCommonControls() SizeOfPointer {
// TODO
tofitaDebugLog("InitCommonControls()\n".utf16())
return 0
}

@linkName('_DllMainCRTStartup_TODO')
#if bit32
@stdcall
@stdcall
#else
@fastcall
@fastcall
#end
fun _DllMainCRTStartup(
unusedX Any,
unusedY Any,
unusedZ Any
unusedX Any,
unusedY Any,
unusedZ Any
) Void {
// TODO
// TODO
}
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions dlls/comctl32.dll/hexa.json → dlls/comctl32/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"global": [
"../types",
"../../engine/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"../tofita32/tofita32.header",
"../kernel32/kernel32.header",
"../ntdll/ntdll.header",
"comctl32.header",
"comctlMain",
"comctl32Vars"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions dlls/gdi32.dll/hexa.json → dlls/gdi32/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"global": [
"../types",
"../../engine/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"../tofita32/tofita32.header",
"../kernel32/kernel32.header",
"../ntdll/ntdll.header",
"gdi32.header",
"gdiMain",
"gdi32Vars"
Expand Down
4 changes: 2 additions & 2 deletions dlls/kernel32.dll/hexa.json → dlls/kernel32/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"global": [
"../types",
"../../engine/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../ntdll.dll/ntdll.header",
"../tofita32/tofita32.header",
"../ntdll/ntdll.header",
"kernel32.header",
"kernelMain",
"kernel32Vars"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ fun localAlloc(flags UInt32, bytes SizeOfPointer) HLocal {
// TODO non-loop align
}

// TODO allocate buffer via VAlloc every time current one is exchausted
return result as! HLocal
}

Expand Down Expand Up @@ -164,6 +165,7 @@ fun getTickCount(stub SizeOfPointer) SizeOfPointer {
tofitaDebugLog("getTickCount()\n".utf16())
return 0
}

@dllExport('GetVersionExW')
fun getVersionExW(stub SizeOfPointer) SizeOfPointer {
// TODO
Expand Down Expand Up @@ -219,6 +221,7 @@ fun setUnhandledExceptionFilter(stub SizeOfPointer) SizeOfPointer {
tofitaDebugLog("setUnhandledExceptionFilter()\n".utf16())
return 0
}

@dllExport('Sleep')
fun sleep(stub SizeOfPointer) SizeOfPointer {
// TODO
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,22 @@ uint64_t __aullrem() asm("__aullrem");
uint64_t __aullrem() { return 0; } // TODO

void _memset() asm("_memset");
void _memset() { } // TODO TODO TODO
#endif
void _memset() {
// TODO
tofitaDebugLog_(L"startup _memset", (uint64_t)((int32_t)0), (uint64_t)((int32_t)0));

} // TODO TODO TODO
#endif

uint64_t bufferOffset_;
void startup() {
// TODO hexa
bufferOffset_ = (int32_t)0;
HEXA_MAIN(0, nullptr);
}

#ifdef bit64
__attribute__((fastcall)) void _DllMainCRTStartup() {
__attribute__((fastcall)) void _DllMainCRTStartup(void *, uint32_t, void *) {
startup();
}
#else
Expand Down
8 changes: 5 additions & 3 deletions dlls/msvcrt.dll/hexa.json → dlls/msvcrt/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"global": [
"../types",
"../../engine/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"../tofita32/tofita32.header",
"../kernel32/kernel32.header",
"../ntdll/ntdll.header",
"msvcrt.header",
"msvcrtMain",
"msvcrtVars"
Expand All @@ -26,6 +26,8 @@
"generator": "c",
"output": "msvcrt.32.c",
"options": [
"extraUnderscore",
"dllExportsNewlineSeparator"
]
}
],
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion dlls/ntdll.dll/hexa.json → dlls/ntdll/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"global": [
"../types",
"../../engine/syscalls/syscalls",
"../tofita32.dll/tofita32",
"../tofita32/tofita32",
"ntdllMain",
"ntdllVars"
],
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions dlls/ntdll.dll/ntdll.hexa → dlls/ntdll/ntdll.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

// TODO @linkName('KiFastSystemCall')
fun kiFastSystemCall(rcx UInt64, rdx Payload) UInt64 {
return tofitaFastSystemCall(rcx as! TofitaSyscalls, rdx)
}
Expand All @@ -23,6 +24,9 @@ declare Entry = (hInstance ConstArrayPointer<Void>, hPrev ConstArrayPointer<Void
declare DllEntry = (hinstDLL ConstArrayPointer<Void>, fdwReason DllEntryReason, lpvReserved ConstArrayPointer<Void>) => Bool32
// TODO must error `hinstDLL` twice `declare DllEntry = (hinstDLL ConstArrayPointer<Void>, fdwReason DllEntryReason, hinstDLL ConstArrayPointer<Void>) => Bool32`

// @rename('hexa_entry') declare let hexa_entry Entry // TODO size_t
// @rename('hexa_pid') declare let hexa_pid UInt64 // TODO size_t
// @rename('hexa_dllEntries') declare let hexa_dllEntries UInt64 // TODO size_t
@rename('hexa_startup') declare let hexa_startup UInt64 // TODO size_t aka PointerSizedUInt (size_t is guaranteed to be an unsigned type)

@dllExport('memset')
Expand All @@ -44,6 +48,14 @@ fun greenteaosIsTheBest(startup ProcessStartupInformation) {
// TODO init DLLs
// TODO PEB/TEB
// TODO TLS callbacks [before EXE entry]

/* - look for IMAGE_TLS_DIRECTORY (IMAGE_DIRECTORY_ENTRY_TLS) and AddressOfCallBacks must be not 0. So this is real entry point(s) of this EXE - no other option, otherwise EXE will crashes.
So solution is to look for IMAGE_DIRECTORY_ENTRY_TLS.AddressOfCallBacks or set breakpoint to LdrpCallTlsInitializers*/

/*
really this was CLR (.NET) image - in this images type entry point is formal and not used after xp. system ignore it and call _CorExeMain in mscoree.dll as entry point.
https://msdn.microsoft.com/en-us/library/xh0859k0(v=vs.110).aspx
*/
// TODO delay-loaded DLLs
// TODO load DLLs in user mode
tofitaDebugLog("CRT ready for PID %u".utf16(), pid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@
STUB(fabs)
STUB(fmod)
STUB(log)
STUB(log10)
STUB(log10) ????????
STUB(pow)
STUB(sin)
STUB(sinh)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions dlls/shell32.dll/hexa.json → dlls/shell32/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"global": [
"../types",
"../../engine/syscalls/syscalls",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"../kernel32/kernel32.header",
"../ntdll/ntdll.header",
"shell32.header",
"shellMain",
"shell32Vars"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions dlls/user32.dll/hexa.json → dlls/user32/hexa.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"global": [
"../types",
"../../engine/syscalls/syscalls",
"../tofita32.dll/tofita32.header",
"../kernel32.dll/kernel32.header",
"../ntdll.dll/ntdll.header",
"../tofita32/tofita32.header",
"../kernel32/kernel32.header",
"../ntdll/ntdll.header",
"user32.header",
"userMain",
"user32Vars"
Expand Down
File renamed without changes.
12 changes: 10 additions & 2 deletions dlls/user32.dll/user32.hexa → dlls/user32/user32.hexa
Original file line number Diff line number Diff line change
Expand Up @@ -475,10 +475,18 @@ fun closeClipboard(stub SizeOfPointer) SizeOfPointer {
return 0
}

// TODO rename to `UIntOfPointer` or `UIntPointer`
@dllExport('CreateDialogParamW')
fun createDialogParamW(stub SizeOfPointer) SizeOfPointer {
fun createDialogParamW(
hInstance HInstance,
lpTemplateName ConstArrayPointer<ClangWideChar>,
hWndParent HWnd,
lpDialogFunc WindowProcedure,
dwInitParam LParam
) HWnd {
// TODO
return 0
tofitaDebugLog("[user32] CreateDialogParamW called".utf16())
return 1 as! HWnd
}

@dllExport('CreatePopupMenu')
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 47bad4f

Please sign in to comment.