This software and its source code (if available) are licensed under the Apache-2.0 license (unless otherwise specified) which DOES NOT APPLY to any third-party code (such as zlib for example) and borrowed Assembler code (ripped code from other software executable files).
#include <windows.h>
#define MAGIC_DV 0x21215644
#pragma pack(push, 1)
typedef struct {
DWORD magic;
DWORD data[3];
DWORD width;
DWORD height;
} dvf_head;
#pragma pack(pop)
void ProcWrite(HANDLE hpc, void *dst, void *src, DWORD len) {
DWORD dw, old;
if (VirtualProtectEx(hpc, dst, len, PAGE_EXECUTE_READWRITE, &old)) {
WriteProcessMemory(hpc, dst, src, len, &dw);
FlushInstructionCache(hpc, dst, len);
VirtualProtectEx(hpc, dst, len, old, &old);
}
}
HWND ProcReadHWND(HANDLE hpc, void *dst) {
DWORD dw;
HWND hw;
hw = 0;
if (!ReadProcessMemory(hpc, dst, &hw, 4, &dw)) {
hw = 0;
}
return(hw);
}
void DVReadHead(char *s, void *p, DWORD l) {
HANDLE fl;
ZeroMemory(p, l);
fl = CreateFile(s, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0);
if (fl != INVALID_HANDLE_VALUE) {
ReadFile(fl, p, l, &l, NULL);
CloseHandle(fl);
}
}
int main(int argc, char *argv[]) {
PROCESS_INFORMATION pi;
STARTUPINFO si;
RECT rc;
DWORD i;
dvf_head dh;
HWND hw;
if (argc != 2) {
MessageBox(0, "Drag and drop .DV video file to this application program icon.", "dvplayer", MB_ICONINFORMATION | MB_OK);
return(1);
}
DVReadHead(argv[1], &dh, sizeof(dh));
if (dh.magic != MAGIC_DV) {
MessageBox(0, "Error: invalid input file format or file doesn't exists.", argv[1], MB_ICONERROR | MB_OK);
return(2);
}
ZeroMemory(&si, sizeof(si));
si.cb = sizeof(si);
if (!CreateProcess(NULL, "angel.exe", NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi)) {
MessageBox(0, "Error: \"angel.exe\" executable not found or error executing.", "dvplayer", MB_ICONERROR | MB_OK);
return(3);
}
/* 0x4096A3 - EB xx (75 0C) and 75 00 before playing */
/*ProcWrite(pi.hProcess, (void *) 0x4096A3, 0xEB, 1);*/
i = 0xEB;
/* 401B9E = EB - always No-CD */
ProcWrite(pi.hProcess, (void *) 0x401B9E, &i, 1);
/* 0x401ABD+1 = 00 - always "-windowed" */
i = 0x00;
ProcWrite(pi.hProcess, (void *) 0x401ABE, &i, 1);
/* 0x401C2E+1 - filename address to play (0x444928 - filename buffer) */
i = 0x00444928;
ProcWrite(pi.hProcess, (void *) 0x401C2F, &i, 4);
ProcWrite(pi.hProcess, (void *) 0x444928, argv[1], strlen(argv[1]) + 1);
/* 0x401C1D+1 - height */
ProcWrite(pi.hProcess, (void *) 0x401C1E, &dh.height, 4);
/* 0x401C22+1 - width */
ProcWrite(pi.hProcess, (void *) 0x401C23, &dh.width, 4);
/* 0x40E79B+1 - ignore "main bigfile not found" */
i = 0xEB;
ProcWrite(pi.hProcess, (void *) 0x40E794, &i, 1);
/* 0x401C2A 6A 00 to infinite loop */
i = 0xFEEB;
ProcWrite(pi.hProcess, (void *) 0x401C2A, &i, 2);
ResumeThread(pi.hThread);
/* 10 seconds */
for (i = 0; i < 1000; i++) {
hw = ProcReadHWND(pi.hProcess, (void *) 0x48688C);
/* window created */
if (hw) { break; }
Sleep(10);
}
/* window not found */
if (!hw) {
CloseHandle(pi.hThread);
TerminateProcess(pi.hProcess, 0);
CloseHandle(pi.hProcess);
return(4);
}
Sleep(1000);
ZeroMemory(&rc, sizeof(rc));
rc.right = dh.width;
rc.bottom = dh.height;
AdjustWindowRect(&rc, GetWindowLong(hw, GWL_STYLE), FALSE);
SuspendThread(pi.hThread);
/* 00401C2A: 6A00 y
00401C2C: 6A00 x */
/* restore command */
i = (rc.top < 0) ? (-rc.top) : rc.top;
i = (i < 128) ? i : 127;
i = (i << 8) | 0x6A;
/*i |= 0x006A;*/
ProcWrite(pi.hProcess, (void *) 0x401C2A, &i, 2);
i = (rc.left < 0) ? (-rc.left) : rc.left;
i = (i < 128) ? i : 127;
i = (i << 8) | 0x6A;
/*i |= 0x006A;*/
ProcWrite(pi.hProcess, (void *) 0x401C2C, &i, 2);
/* call exit() on "file not found in archive" */
i = 0x00026CF4;
ProcWrite(pi.hProcess, (void *) 0x40E81E, &i, 4);
/* make sure call above will work - corrupt next resource name */
i = '?';
ProcWrite(pi.hProcess, (void *) 0x442278, &i, 1);
ResumeThread(pi.hThread);
MoveWindow(hw, 0/*rc.left*/, 0/*rc.top*/, rc.right - rc.left, rc.bottom - rc.top, TRUE);
CloseHandle(pi.hThread);
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hProcess);
return(0);
}