• Welcome! The TrekBBS is the number one place to chat about Star Trek with like-minded fans.
    If you are not already a member then please register an account and join in the discussion!

C++ still used in the 23rd century

marsh8472

Fleet Captain
Fleet Captain
GOZa6JPX.jpg

This comes from S01E03 of discovery

https://github.com/Laurelai/decompi...8DF1A2B905/37FC7C5D89F1E5A96F54318DF1A2B905.c <-- I see this code there

// DWORD __stdcall GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
// BOOL __stdcall GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation);
// HMODULE __stdcall GetModuleHandleW(LPCWSTR lpModuleName);
// BOOL __stdcall SetFileTime(HANDLE hFile, const FILETIME *lpCreationTime, const FILETIME *lpLastAccessTime, const FILETIME *lpLastWriteTime);
// BOOL __stdcall WriteFile(HANDLE hFile, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten, LPOVERLAPPED lpOverlapped);
// DWORD __stdcall GetFileAttributesW(LPCWSTR lpFileName);
// HANDLE __stdcall CreateFileW(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile);
// int __stdcall lstrlenW(LPCWSTR lpString);
// FARPROC __stdcall GetProcAddress(HMODULE hModule, LPCSTR lpProcName);
// BOOL __stdcall CloseHandle(HANDLE hObject);
// BOOL __stdcall DeleteFileW(LPCWSTR lpFileName);
// LPWSTR __stdcall lstrcpyW(LPWSTR lpString1, LPCWSTR lpString2);
// BOOL __stdcall SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes);
// HANDLE __stdcall GetCurrentProcess();
// void __stdcall SetLastError(DWORD dwErrCode);
// int __stdcall lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2);
// DWORD __stdcall GetCurrentThreadId();
// DWORD __stdcall GetCurrentProcessId();
// int __stdcall lstrcmpA(LPCSTR lpString1, LPCSTR lpString2);
// BOOL __stdcall IsBadReadPtr(const void *lp, UINT_PTR ucb);
// DWORD __stdcall GetModuleFileNameW(HMODULE hModule, LPWCH lpFilename, DWORD nSize);
// int __stdcall lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2);
// HMODULE __stdcall GetModuleHandleA(LPCSTR lpModuleName);
// BOOL __stdcall VirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWORD lpflOldProtect);
// LPWSTR __stdcall lstrcatW(LPWSTR lpString1, LPCWSTR lpString2);
// BOOL __stdcall VirtualFree(LPVOID lpAddress, SIZE_T dwSize, DWORD dwFreeType);
// LPWSTR __stdcall lstrcpynW(LPWSTR lpString1, LPCWSTR lpString2, int iMaxLength);
// BOOL __stdcall ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
// LPVOID __stdcall VirtualAlloc(LPVOID lpAddress, SIZE_T dwSize, DWORD flAllocationType, DWORD flProtect);
// HANDLE __stdcall CreateMutexW(LPSECURITY_ATTRIBUTES lpMutexAttributes, BOOL bInitialOwner, LPCWSTR lpName);
// UINT __stdcall SetErrorMode(UINT uMode);
// BOOL __stdcall FreeLibrary(HMODULE hLibModule);

In the scene they were showing the code, they were pointing out errors with commented out code. Then they expanded one of the commented out lines with a snibbit of code further down and omitted some of the code below that's not in bold.

v5 = GetModuleHandleW(L"NTDLL.DLL");

v4 = GetProcAddress(v5, "ZwSetInformationFile");

if ( !v4

|| (v7 = *(_DWORD *)(a1 + 4),

v13 = *(_DWORD *)a1,

v8 = *(_DWORD *)a2,

v14 = v7,

v9 = *(_DWORD *)(a2 + 4),

v15 = v8,
v10 = *(_DWORD *)a3,
v16 = v9,
v11 = *(_DWORD *)(a3 + 4),
v17 = v10,
v19 = v10,
v18 = v11,
v20 = v11,
v21 = 128,
(result = ((int (__stdcall *)(void *, char *, int *, signed int, signed int))v4)(a4, &v12, &v13, 40, 4)) != 0) )
result = SetFileTime(a4, (const FILETIME *)a1, (const FILETIME *)a2, (const FILETIME *)a3);


It looks like a decompiled C++ app. Because it's decompiled the variables are all badly named (v1, v2, v3, ... a1, a2, a3, ...)
 
Strangely, this threw my suspension of disbelief for a loop because it looks just like real-life computing. :wtf:

Kor
 
Objective-C is nice. And I have always had a soft spot for good old ANSII C.

C++ and its abomination of a successor C#, however, can disappear into the mists of time forever, as far as I'm concerned.

And Java. Java too.

Does anyone still use SmallTalk or Common LISP anymore? Those languages can fuck off too.
 
Last edited:
If you are not already a member then please register an account and join in the discussion!

Sign up / Register


Back
Top