NTSTATUS InitializeRedirectEntry() { NTSTATUS Status; UNICODE_STRING ExePath; PLDR_MODULE Module; PWSTR Buffer; ULONG_PTR Length; PFILE_REDIRECT_ENTRY Entry, RedirectEntry; static FILE_REDIRECT_ENTRY RedirectSubDirectory[] = { REDIRECT_PATH(L"data\\", L"patch\\"), REDIRECT_PATH(L"data\\", L"patch2\\"), }; Module = FindLdrModuleByHandle(NULL); Status = NtFileDisk::QueryFullNtPath(Module->FullDllName.Buffer, &ExePath); FAIL_RETURN(Status); RedirectEntry = (PFILE_REDIRECT_ENTRY)AllocateMemoryP((countof(RedirectSubDirectory) + 1) * sizeof(*RedirectEntry), HEAP_ZERO_MEMORY); if (RedirectEntry == NULL) { RtlFreeUnicodeString(&ExePath); return STATUS_NO_MEMORY; } GlobalRedirectEntry = RedirectEntry; ExePath.Length -= Module->BaseDllName.Length; Length = 0; FOR_EACH(Entry, RedirectSubDirectory, countof(RedirectSubDirectory)) { Length = ML_MAX(Entry->Original.Length, ML_MAX(Entry->Redirected.Length, Length)); }
void ui_draw(SDL_Point* viewport) { const int NLINES = 32; if (console_enabled || console_fade > 0) { int console_width = (640 > viewport->x) ? viewport->x : 640; size_t max_display = console_width/UI_CHAR_W - 1; size_t len, offset; float elastic_fade = enQuinticInOut(console_fade); uint32_t alpha = (uint32_t)(ML_MAX(elastic_fade, 0.1f)*255.5f); float yoffs = (float)(NLINES*UI_CHAR_H) * elastic_fade; ui_rect(0, viewport->y - (int)yoffs, console_width, NLINES*UI_CHAR_H, ((alpha * 5 / 6)<<24)|0x2c3e50); ui_rect(0, viewport->y - (int)yoffs - UI_CHAR_H - 4, console_width, UI_CHAR_H + 4, (alpha<<24)|0x34495e); int sby = viewport->y - (int)yoffs + 2; int sbpos = (console_scrollback_pos - 1) % CONSOLE_SCROLLBACK; if (sbpos < 0) sbpos = CONSOLE_SCROLLBACK - 1; while (sbpos != console_scrollback_pos && sby < viewport->y) { if (console_scrollback[sbpos] == '\0') break; len = strlen(console_scrollback[sbpos]); offset = (len > max_display) ? (len - max_display) : 0; ui_text(2, sby, (alpha<<24)|0xbdc3c7, "%s", console_scrollback[sbpos] + offset); sby += UI_CHAR_H; sbpos = (sbpos - 1) % CONSOLE_SCROLLBACK; if (sbpos < 0) sbpos = CONSOLE_SCROLLBACK - 1; } len = strlen(console_cmdline); offset = (len > (max_display - 1)) ? (len - (max_display - 1)) : 0; ui_text(2, viewport->y - (int)yoffs - UI_CHAR_H - 2, (alpha<<24)|0xeeeeec, "#%s", console_cmdline + offset); } if (ui_count > 0) { vec2_t screensize = { (float)viewport->x, (float)viewport->y }; glEnable(GL_BLEND); // glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glUseProgram(ui_material->program); m_tex2d_bind(&ui_font, 0); glUniform2fv(ui_screensize_index, 1, (float*)&screensize); glUniform1i(ui_tex0_index, 0); glBindVertexArray(ui_vao); glBindBuffer(GL_ARRAY_BUFFER, ui_vbo); if (ui_count > ui_maxcount) { glBufferData(GL_ARRAY_BUFFER, (unsigned long)(ui_count)*sizeof(uivert_t), ui_vertices, GL_DYNAMIC_DRAW); ui_maxcount = ui_count; } else { glBufferSubData(GL_ARRAY_BUFFER, 0, (unsigned long)(ui_count)*sizeof(uivert_t), ui_vertices); } glDrawArrays(GL_TRIANGLES, 0, ui_count); glBindVertexArray(0); glUseProgram(0); glDisable(GL_BLEND); // glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); ui_count = 0; } }